[dba-SQLServer]Selecting data into variables

David Emerson davide at dalyn.co.nz
Wed Oct 8 18:00:04 CDT 2003

Thanks but I was looking at more than 1 variable at a time.  I think output 
parameters will do the trick.


At 8/10/2003, you wrote:
>Like this?
>/* -- cut here */
>DECLARE @prod_name varchar(50)
>SELECT @prod_name = productname from products where productid = 4;
>PRINT @prod_name
>/* -- cut here */
>>From: David Emerson <davide at dalyn.co.nz>
>>Reply-To: dba-sqlserver at databaseadvisors.com
>>To: dba-SQLServer at databaseadvisors.com
>>Subject: [dba-SQLServer]Selecting data into variables
>>Date: Wed, 08 Oct 2003 16:55:49 +1300
>>I would like to run a select statement that returns 1 row, then put the 
>>column values into variables I have declared in my Sproc.  The closest I 
>>have come across in BOL is the SELECT INTO statement but this is for 
>>"Embedded SQL for C and SQL Server".
>>I could use a cursor but it seems overkill for only one row.  Is there an 
>>easy way to do this?
>>David Emerson
>>DALYN Software Ltd
>>25b Cunliffe St, Johnsonville
>>Wellington, New Zealand
>>Ph/Fax (877) 456-1205
>>dba-SQLServer mailing list
>>dba-SQLServer at databaseadvisors.com
>Protect your PC - get McAfee.com VirusScan Online
>dba-SQLServer mailing list
>dba-SQLServer at databaseadvisors.com

More information about the dba-SQLServer mailing list