Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Stored Procedure
Message
From
06/11/2009 15:01: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:
01433625
Views:
45
>>Please take the time to mark her message as the solution so others can learn by it.
>>
>>Thanks!
>
>BTW, I corrected again my version - Jim, please review the procedure. I think we do need to use different variables - e.g. in the second version I changed them to InnerStartDate, etc. again - I either got confused too much or something was not working in my tests properly.
Here is the completed sp.
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		ATSI
-- Create date: 11/5/2009
-- Description:	Procedure to retrieve all data from the selected table between the selected dates
-- =============================================
ALTER PROCEDURE [dbo].[GetWellData] 
	-- Add the parameters for the stored procedure here	
	@Tablename sysname,
	@StartDate as datetime,
	@EndDate as datetime

AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from interfering with SELECT statements.
	SET NOCOUNT ON;

	Declare @cmd AS NVARCHAR(max)
	Declare @ParamDefinition NVARCHAR(500)

	SET @ParamDefinition = N'@StartDate datetime, @EndDate datetime'
	SET @cmd = N'Select * from ' + QUOTENAME(@TableName) + 'WHERE Date between @StartDate And @EndDate'
    
	exec sp_executesql @cmd, @ParamDefinition,
		@StartDate = @StartDate,
		@EndDate = @EndDate
END
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform