[dba-SQLServer]SET vs SELECT

Francisco H Tapia my.lists at verizon.net
Wed Oct 8 09:32:54 CDT 2003


with Select you can assign values to multiple variables.  such as

SELECT @Column1 = T.Column1, @Column2 = T.Column2 From Table as T

In BOL it is recommended that the SET command be used instead, this 
maybe because you can use more attributes.

I think in SQL 2k, the Select command was able to be used to populate 
variables (i may be wrong about that).

Billy Pang wrote:

> AFAIK, no difference....
> I usually use SET when assigning a single value and SELECT to set values 
> obtained from a table.
> 
> 
> 
> 
>> From: David Emerson <davide at dalyn.co.nz>
>> Reply-To: dba-sqlserver at databaseadvisors.com
>> To: dba-SQLServer at databaseadvisors.com
>> Subject: [dba-SQLServer]SET vs SELECT
>> Date: Wed, 08 Oct 2003 17:00:43 +1300
>>
>> I have seen these commands used in similar situations.  Eg
>>
>> SET @myVar = 10
>> SELECT @myVar = 10
>>
>> Are they interchangeable or do they have different purposes?
>>
>> Regards
>>



-- 
-Francisco




More information about the dba-SQLServer mailing list