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 - 2012-10-19 : 09:49:56
|
Hello,how do i assign a variable to a table column at runtimehere is my codethanksMselect (select @to = receipient), (@from = senderid), (@msg = [message]) from histories where batch = @counter and username = 'school' _____________________Yes O ! |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-10-19 : 10:00:57
|
The syntax is like shown below, BUT you have to be careful, because if the query returns more than one row, which value from among those will be assigned to your variable is indeterminate. So do this only when you are guaranteed that you will get only one row.SELECT @to = receipient, @from = senderid), @msg = [message]FROM historiesWHERE batch = @counter AND username = 'school' |
 |
|
|
mary_itohan
Posting Yak Master
191 Posts |
Posted - 2012-10-19 : 18:04:22
|
| ok many thanks_____________________Yes O ! |
 |
|
|
|
|
|