T-SQL coding

Assigning Variables – SET vs. SELECT

Assigning values to variables in your T-SQL code…both the SET statement and the SELECT statement are common ways to do this. However, are you aware that the behavior of these 2 statements is different? Depending on which statement you use your results could vary. So, rather than re-write the book on this topic I will just refer you to this good summary of the differences:


Although the SET statement is the ANSI standard, the SELECT statement does have its uses. In many cases you can use either method, but your coding should be different to account for the differences that can occur in the resulting assignment.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s