April 10, 2003 at 10:18 am
Hi folks,
trying to set the default and date to today ... I know that I must be mising something stupid ... here is what I have:
CREATE PROCEDURE rptCurrentInCome
@RunnerID INT=NULL,
@StartDate DATETIME='01/01/1900',
@EndDate DATETIME=GETDATE()
AS ...
Edited by - robby_disco on 04/10/2003 10:19:13 AM
April 10, 2003 at 10:33 am
Default parameters must be NULL or a Constant. GETDATE is obviously not a constant.
Try:-
alter PROCEDURE rptCurrentInCome
@RunnerID INT=NULL,
@StartDate DATETIME='01/01/1900',@EndDate DATETIME=NULL
AS
if @enddate is null set @enddate = GETDATE()
...
April 10, 2003 at 10:38 am
According to BOL: "The CREATE PROCEDURE statement cannot be combined with other Transact-SQL statements in a single batch."
So I guess you can't combine GETDATE() with CREATE PROC. May be you can just do ... err... wait, ianscarlett already answered what I wanted to say. 😛
April 10, 2003 at 10:38 am
Robby,
Yeah... looks like T-SQL doesn't like function calls in proc declarations. I didn't know that. You could set the date to GetDate() after the parameter declarations:
CREATE PROCEDURE rptCurrentInCome
@RunnerID INT=NULL,
@StartDate DATETIME='01/01/1900',
@EndDate DATETIME=NULL
AS
SET @EndDate = GetDate()
.
.
.
HTH,
SJTerrill
April 14, 2003 at 2:08 pm
Thanks for the help folks ...
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply