Friday, October 24, 2014

SQL Server - Stored Proc Skeleton


USE [collateral]
GO

if exists(select * from sys.objects where Name = 'sproc_name' and type = 'P')
 drop procedure sproc_name 
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE sproc_name 
 @intParam int
AS
BEGIN
 SET NOCOUNT ON;

 begin transaction [txn]

 begin try

  -- sproc sql here

 commit transaction [txn]

 end try
 begin catch
  rollback transaction [txn]
 end catch

END
GO

Thursday, October 23, 2014

MS SQL Server - Query Results - to Text versus to Grid

MS SQL Server ShortCut Keys

Output results in a grid:  Ctrl+Shift+D (2014) or Ctrl+D (2008R2)
Output results in text:  Ctrl+T (2014, 2008R2)
 .