Thursday, August 23, 2012

T-SQL Syntax

Recently I have came across very good question on SQLServerCentral.com
Different T-SQL constructs can assign a value to a regular identifier with a leading '@' without using SET nor SELECT :
  1. An Input argument to a Procedure or Function - http://msdn.microsoft.com/en-us/library/ms187926
  2. An Output argument to a Procedure - http://msdn.microsoft.com/en-us/library/ms187926
  3. EXECUTE a Function: EXEC @return = udfFunct() - http://msdn.microsoft.com/en-us/library/ms188332
  4. The Stored Procedure return status: EXEC @status = uspProc (This is very different from a Function return.) - http://msdn.microsoft.com/en-us/library/ms188332
  5. The OUTPUT clause: OUTPUT INTO @tablevar (Could count this 4 times but it is really one construct) http://msdn.microsoft.com/en-us/library/ms177564
  6. RECEIVE .... FROM INTO @tablevar - http://msdn.microsoft.com/en-us/library/ms186963.aspx
  7. FETCH NEXT FROM cursor INTO @varname - http://msdn.microsoft.com/en-us/library/ms180152
  8. DECLARE @varname INT = 0; - http://msdn.microsoft.com/en-us/library/ms188927

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.