17.07.2015 Views

Defensive Database Programming - Red Gate Software

Defensive Database Programming - Red Gate Software

Defensive Database Programming - Red Gate Software

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 5: Reusing T-SQL CodeLet's say we have a stored procedure that returns all sales for the month, across all states,as shown in Listing 5-13.CREATE PROCEDURE dbo.SelectSalesForMonth @AsOfDate DATETIMEASBEGIN ;SELECT Amount ,StateCodeFROM dbo.SalesWHERE SaleDateTime >= DATEADD(day, -29, @AsOfDate)AND SaleDateTime

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!