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 |
|
ujjaval
Posting Yak Master
108 Posts |
Posted - 2006-01-11 : 22:30:07
|
| I am running following query,select ID, firstName, lastName from Person where ID = 2Assumption: ID is a primary key in Person table.now, above query will give me 1 result.I want to store ID, firstName and lastName returned from this query into three separate variables. I am using SQL Server 7. Is there anyway that I can directly store this value into three different variables.. or I have to do this:set @firstName = (select firstName from Person where ID = 2)set @lastName = (select lastName from Person where ID = 2)Thanks,Ujjaval |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-01-11 : 22:33:18
|
| [code]select @ID = ID, @firstName = firstName, @lastName = lastNamefrom Personwhere ID = 2[/code]CODO ERGO SUM |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-01-12 : 02:31:00
|
| >>set @firstName = (select firstName from Person where ID = 2)Dont use this type of assignment. You will get error if the query returns more then one value if anyMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|