Wednesday, September 12, 2012

Useful commands/statements



1. Check if Procedure exist before creating it

EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'MyProc')

Return bool

Ex.
IF EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'MyProc')
DROP PROCEDURE MyProc
GO
CREATE PROCEDURE MyProc...

2.

SET NOCOUNT ON  - Stops the message indicating the number of rows affected by a Transact-SQL statement from being returned as part of the results.
For stored procedures that contain several statements that do not return much actual data, this can provide a significant performance boost because network traffic is greatly reduced.

3.  SP
 sp_help [object] provides info on object

No comments:

Post a Comment