Jump to content

Generating Multiple rows based on quantity column value?


SJR19

Recommended Posts

Ok my query gives me these results.

BatchID | Batch_Item_Count

-------------------------------------------

1514021901 | 12

I need results to look like this

BatchID I Batch_Item_Count

------------------------------------------

1514021901 | 0001514021901 I 0011514021901 I 0021514021901 | 0031514021901 | 0041514021901 | 0051514021901 | 0061514021901 | 007 1514021901 | 0081514021901 | 0091514021901 | 0101514021901 | 011

I hope this is a OK example.

I trying to duplicate a row that in table for a batch that was created the batch has 12 items in it. I need to label these 12 items. So I need the BatchID to stay the same and for the row to be duplicated 12 times and format the batch_Item_Count like this 000 through to 011. The max amount of items that can be batches in 999. I need this to work for any amount of items in a batch from 1 to 999.

Edited by SJR19
Link to comment
Share on other sites

I'm not sure if a basic query will let you create a result like that, you might need to use a stored procedure to build that by inserting a bunch of rows into a temporary table and then selecting everything from the table.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...