Hi, I have written a simple procedure:
CREATE PROCEDURE [dbo].[sp_GetPublishedDocs2] @FromDate as Datetime AS BEGIN
DECLARE @strSQL VARCHAR(5000)
SET @strSQL='SELECT * From Task WHERE 1=1 '
IF @FromDate <>'1/1/1900'
SET @strSQL = @strSQL + ' AND Task.CreatedDate >= '+Cast(@FromDate as Datetime)
EXEC(@strSQL)
END
It run successfully when I pass parameter '1/1/1900' however when I pass any other date it says: Conversion failed when converting date and/or time from character string.
Is there anyone.. who could help me...
Thanks in Advance.