Is it alright to write the following SP this way (aside from sql injections)?
The code works right.
What I have is a function which receives two Date parameters and gets records from a table based on the Date criteria.
Then this SP uses uses also a parameter and runs a Select statement off of the Function, passing additional criteria is desired.
Also, how to use the Date Parameters in function in the Select statement properly (doesn't look right to me).
The code works right.
What I have is a function which receives two Date parameters and gets records from a table based on the Date criteria.
Then this SP uses uses also a parameter and runs a Select statement off of the Function, passing additional criteria is desired.
Also, how to use the Date Parameters in function in the Select statement properly (doesn't look right to me).
Code:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[TestfBP]
@DateStart DateTime,
@DateEnd DateTime,
[b]@OtherCriteria VarChar(1000)[/b]
AS
BEGIN
SET NOCOUNT ON;
EXECUTE ('SELECT * FROM fMyFunction('''+@DateStart+''','''+@DateEnd+''') '+[b]@OtherCriteria[/b])
END
GO
EXEC [dbo].[TestfBP] '23-01-2008','23-01-2008',[b]'WHERE SomeField=''64279'''[/b]
GO