Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
benking9987
Posting Yak Master
124 Posts |
Posted - 2013-09-18 : 16:57:01
|
I have a table that contains:item | quantity123 | 1456 | 10789 | 4I need to get this data listed into a table that just has item and for it to look like this:123456456456456456456456456456456789789789789I understand and have accounted for the obvious primary key issue. I just can't figure out how to get the data to display out like this.Any thoughts?Thanks in advance. |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-09-18 : 17:09:24
|
[code]SELECT itemFROM YourTable a CROSS JOIN master.dbo.spt_values bWHERE b.type = 'P' AND b.number < a.quantity; [/code]If you have more than 2048 quantity in any row, and when you want to use it in production, use a numbers table rather than spt_values table. |
|
|
benking9987
Posting Yak Master
124 Posts |
Posted - 2013-09-18 : 17:26:03
|
Flawless! Thank you James K. |
|
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-09-18 : 17:45:28
|
You are very welcome - glad to help. |
|
|
|
|
|