I've been working on some TSQL where I have a stored procedure that accepts two date parameters for a report that will be built in Reporting Services. Here's the created stored procedure:
SQL
CREATEPROCEDURE[dbo].[spReportDom2](@FromDateDateTime,@ToDateDateTime)ASBEGINDECLARE@ToplineTABLE(TopLinenumeric(9,2),OfficeNamevarchar(100))DECLARE@CostOfGoodsTABLE(CostOfGoodsnumeric(9,2),OfficeNamevarchar(100))DECLARE@Querynvarchar(1000)DECLARE@Query2nvarchar(1000)-------ARIZONASELECT@Query=' SELECT SUM(Amount) AS TopLine, (SELECT Office.Name FROM Arizona.dbo.Office WHERE Office.ID=VW.OfficeID) as OfficeName FROM Arizona.dbo.ViewIncomeStatement VW (NOLOCK) WHERE SectionName=''Revenues'' AND VW.EffectiveDate BETWEEN ''04/11/2015'' AND ''04/18/2015'' GROUP BY OfficeID'SELECT@Query2=' SELECT SUM(Amount)as CostOfGoods,...