Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Stored Procedure
Message
From
06/11/2009 14:57:01
 
 
To
06/11/2009 14:51:46
General information
Forum:
ASP.NET
Category:
Databases
Environment versions
Environment:
C# 3.0
OS:
Windows XP SP2
Database:
MS SQL Server
Miscellaneous
Thread ID:
01433610
Message ID:
01433622
Views:
47
>>>>>I didn't look too close yet, but looks like there is an extra comma at the end of cmd line - not sure how did it get there.
>>>>
>>>>Right, I took out the extra commas, and it saved successfully, but when I tried to run it, I get this:
>>>>
>>>>Must declare the scalar variable "@StartDate".
>>>
>>>Getting this error right now - give me a sec.
>>
>>Of course!!!
>>
>>Here is the correct version
>>
>>
>>-- Test query
>>alter PROCEDURE [dbo].[GetWellData] 
>>	-- Add the parameters for the stored procedure here	
>>	@Tablename sysname,	 
>>	@StartDate datetime,
>>	@EndDate datetime
>>AS
>>BEGIN
>>	-- SET NOCOUNT ON added to prevent extra result sets from interfering with SELECT statements.
>>	SET NOCOUNT ON;
>>	SET @TableName = RTRIM(@TableName)
>>
>>	Declare @cmd AS NVARCHAR(max)
>>   DECLARE @ParmDefinition NVARCHAR(500)
>>   SET @ParmDefinition = N'@StartDate datetime ,@EndDate datetime'
>>
>>	SET @cmd = N'Select * from ' + QUOTENAME(@TableName) + ' where BidDateTime between @StartDate and @EndDate'
>>    
>>	exec sp_executesql @cmd, @ParmDefinition,
>>            @StartDate = @StartDate,
>>            @EndDate  = @EndDate
>>END
>>go
>>
>>execute GetWellData 'Bid', '20081001','20091101'
> That did it, Thanks Naomi.

Please take the time to mark her message as the solution so others can learn by it.

Thanks!
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform