Here is The Combined answer that i have collected from various articles and experience. Here is the Difference. 1. SET is the ANSI standard for variable assignment, SELECT is not. 2. You can use SELECT to assign values to more than one variable at a time. SET allows you to assign data to only one variable at a time. Here's how: /* Declaring variables */ DECLARE @Variable1 AS int, @Variable2 AS int /* Initializing two variables at once */ SELECT @Variable1 = 1, @Variable2 = 2 /* The same can be done using SET, but two SET statements are needed */ SET @Variable1 = 1 SET @Variable2 = 2 3. When assigning from a query if there is no value returned then SET will assign NULL, where SELECT will not make the assignment at all (so the variable will not be changed from it's previous value) . 4. When using a query to populate a variable, SET will fail with an error, if the query returns more than one value. But SELECT will assign one of ...
I love Programming, and Eager to learn New things Curious about Microsoft Products, Interested in Knowledge sharing. If you can dream IT, You can become it, If you can think IT, You can do IT, If you can believe it, you can achieve IT.