SQL Server - Pass GetDate() in SP
Asked By farrukh on 01-Aug-12 06:29 AM
Hello Experts !
I want to run stored procedure for current date time its below i am correct ?
CREATE PROCEDURE PROC_NAME
@StartDate datetime = null ,
@EndDate datetime = null
SET @StartDate = COALESCE(@StartDate, GETDATE())
SET @EndDate = COALESCE(@EndDate, GETDATE())
Update table1 set column_1=
(select column_2 from table2......)
Peter Bromberg replied to farrukh on 01-Aug-12 02:00 PM
YOU do not need to use the COALESCE function as getDate() already returns a DateTime object:
SET @StartDate = GETDATE()
SET @EndDate = GETDATE()
if you use COALESCE and the @StartDate is not null, that would then be the value that is assigned.