Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Database Administration and Security

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-08-07 : 07:43:24
Rajesh writes "I am passing input variable as a datetime to a stored procedure
How to compare date variable with datetime column.
Does I require to covert the variable while comparing ?


CREATE PROCEDURE PROC_SETTLEMENT (@TrdSettlementDate)
AS
BEGIN
SELECT * FROM Settlement where @TrdSettlementDate >= @StartDate and @TrdSettlementDate <=@EndDate
END"

Andraax
Aged Yak Warrior

790 Posts

Posted - 2003-08-07 : 07:47:01
No, but you have to type the parameter. Also, BEGIN and END are not necessery in this case. I presume StartDate and EndDate are columns in the table and not variables/parameters? So you have to lose the @:

CREATE PROCEDURE PROC_SETTLEMENT (@TrdSettlementDate datetime)
AS

SELECT * FROM Settlement where @TrdSettlementDate >= StartDate and @TrdSettlementDate <= EndDate
Go to Top of Page
   

- Advertisement -