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 |
|
mary_itohan
Posting Yak Master
191 Posts |
Posted - 2008-09-13 : 16:53:32
|
| Hello, I will like to know whats the most efficient way of achieving this ?I have a table with multiple columns i want to assign to variables. 1. Do I run a select command each time i want to assign each column to a variable ???2. Or is there a better and more efficient way or achieving this ?declare @a varchar(20),@b varchar(20),@c varchar(20)set @a = select columnA from testtable where user = 'test'set @b = select columnB from testtable where user = 'test'set @c = select columnC from testtable where user = 'test'Hope this is clear ?thanks_____________________Yes O ! |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
mary_itohan
Posting Yak Master
191 Posts |
Posted - 2008-09-13 : 17:46:20
|
| thanks Tkizer_____________________Yes O ! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-14 : 09:24:26
|
| are you sure you'll have a single value returned for each column from table (single record existing for user = 'test'). if not what you need is to oput it to temporary table.variables can hold only one value at a time so if you've multiple values coming variable will have only a single value. |
 |
|
|
|
|
|