SQL problem
-
Dear friends, I want to execute a query in SQL - Server but i want the result in variable. For this purpose i am successfully doing something like this:
DECLARE @num int SELECT @num = (select salary from mytable where id=2) PRINT @num
In above query i only select one field from the table i.e salary. Now can anyone tell me that how can i collect values of multiple fields in variables. e.g(select name, salary from mytable where id=2)
In this case i am selecting two fields from a table i.e name, salary. Now how can i get these two values in variables. Any suggestion is welcomed. Thanks -
Dear friends, I want to execute a query in SQL - Server but i want the result in variable. For this purpose i am successfully doing something like this:
DECLARE @num int SELECT @num = (select salary from mytable where id=2) PRINT @num
In above query i only select one field from the table i.e salary. Now can anyone tell me that how can i collect values of multiple fields in variables. e.g(select name, salary from mytable where id=2)
In this case i am selecting two fields from a table i.e name, salary. Now how can i get these two values in variables. Any suggestion is welcomed. Thanks