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


Top 5 Contributors of the Month
david stephan

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)
as
SELECT 'Forecasted' AS HeadCount,[@date1]
FROM
(SELECT *
FROM SAR_HeadCount) AS SourceTable
PIVOT
(
SUM(HeadCount)
FOR StartDate IN [@date1]
) AS PivotTable;


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

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



Regards
Santosh

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

Hi,

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
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

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