| Author |
Topic |
|
tmaiden
Yak Posting Veteran
86 Posts |
Posted - 2007-09-20 : 16:19:30
|
| How can I do thisSelect id set @temp = idfrom tblexampleI want to do something, on each row output, with @temp. |
|
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2007-09-20 : 16:22:07
|
| Select @temp = idfrom tblexampleAssuming there is only one Id in the table. If you have multiple rows, you need to restrict the result with proper WHERE condition.Dinakar Nethi************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
|
tmaiden
Yak Posting Veteran
86 Posts |
Posted - 2007-09-20 : 16:30:31
|
| there is know way to do it with each row? |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-09-20 : 16:38:34
|
| You would have to loop through them using WHILE.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2007-09-20 : 16:38:34
|
| What exactly are you trying to do?Dinakar Nethi************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
|
tmaiden
Yak Posting Veteran
86 Posts |
Posted - 2007-09-20 : 16:49:36
|
| In my table I have a field called "tracknum" in this field normally is just one number (ex: 2342). Depending upon how many items are being sold (qty) the tracknum field is appened to.Example: orderid, productid, qty, tracknum1, 1, 1, '2343'2, 1, 4, '2344/2345/2346/2347'I am trying to break these 4 items (orderid = 2) into 4 seperate rows.2, 1, 1, 23442, 1, 1, 23452, 1, 1, 23462, 1, 1, 2347I have no clue how to do this. This orginal post is about a function I was trying to use but its not going to work anyway. |
 |
|
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2007-09-20 : 16:59:38
|
| Look for the split function here: http://weblogs.sqlteam.com/dinakar/archive/2007/03/28/60150.aspx If you look in the comments I also posted a function that takes a delimited list and returns a table. You can tweak that to get your results.Dinakar Nethi************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|