Solved

Using SET versus SELECT

Posted on 2001-06-25
6
233 Views
Last Modified: 2008-02-20
What is the difference?  Is either way better?  Any tips?
0
Comment
Question by:svfafel
6 Comments
 
LVL 18

Expert Comment

by:nigelrivett
ID: 6225522
Microsoft advise set as ansii standard but there isn't much difference (except learning to type two different words).
0
 
LVL 3

Expert Comment

by:mgmanoj
ID: 6225661
Set is to assign the values to a variable or expressions to a variable & it does not displays the result in output while select displays in the result set it can be also used to assign.
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 100 total points
ID: 6226470
i agree with mgmanoj, especially if you have stored procedures with SELECT instead of SET, you might need to
use the SET NOCOUNT ON at the beginning of the stored procedure to avoid the "empty" recordsets...

CHeers
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 2

Expert Comment

by:ZhongYu
ID: 6226656
In the case of assignment, like set @test=1, you can use whichever you like. SET is ansi standard, its more clean to me. SELECT let you assign several values at the same time.
 

0
 

Author Comment

by:svfafel
ID: 6227561
Thank you to all!!! I wish i could give points to everyone....
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6227611
For mgmanoj:
http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=mssql&qid=20141705

Sorry nigel, as you did only complain, no points today! (just joking)
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question