DECLARE @orderyear int = 2007; SELECT orderyear, qty FROM Sales.OrderTotalsByYear WHERE orderyear = @orderyear;
- 9. Designing and Creating Views, Inline Functions, and Synonyms
- from Training Kit (Exam 70-461): Querying Microsoft® SQL Server® 2012
- Publisher: Microsoft Press
- Released: December 2012
Using DECLARE @ is an option at the beginning of queries where multiple table expressions result in different date sets, YoY comparisons for example. It makes the date manipulation easier as you don't have to scan the query code for the dates to update when changing periods.
Share this highlighthttp://www.safaribooksonline.com/a/training-kit-exam/78454/