.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Imran Ghani
Sohaib Khalid

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

How to pass dynamic dates to pivot query through stored procedure

Posted By: Naresh     Posted Date: October 04, 2010    Points:2   Category :ASP.Net
Hi All,

I am getting error as incorrect syntax near @date1.If i pass date directly i am getting result.

create procedure Sample(@date1 datetime,@date2 datetime,@date3 datetime,@date4 datetime,@CampaignID int)
SELECT 'Forecasted' AS HeadCount,[@date1]
FROM SAR_HeadCount) AS SourceTable
FOR StartDate IN [@date1]
) AS PivotTable;

Author: Santosh             
Posted Date: October 04, 2010     Points: 5   

hi Naresh
i m not clear abt ur doubt...


Author: Naresh             
Posted Date: October 05, 2010     Points: 5   


I am using storedprocedure with pivot.
From front end i will pass 4 dates based on that i need to generate reports like this

HeadCount 8/1/2010 8/8/2010 8/15/2010 8/22/2010

Forecatsed HC 191 196 178 169

This is table data.Dates are dynamic.I am trying pass
dynmaic dates to storedprocdure but getting error.When i run the stored procedure i am getting error.

HeadCount StartDate
191 8/1/2010
196 8/8/2010
189 8/15/2010
176 8/22/2010

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend