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
 Transact-SQL (2000)
 Stored Procedure default value

Author  Topic 

Antonio
Posting Yak Master

168 Posts

Posted - 2005-09-07 : 11:14:52
Greetings!

Could someone out there tell me why I can't use the following as my default value for a parameter?


create procedure Check_And_Balances_Process

@Start_Date int = cast(convert(varchar, dateadd(dd, -30, getdate()), 112) as int)

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-09-07 : 11:28:00
Greetings to you!

From Books Online:
quote:
default

Is a default value for the parameter. If a default is defined, the procedure can be executed without specifying a value for that parameter. The default must be a constant or it can be NULL.
You have tried to make the default an expression rather than a constant.


Be One with the Optimizer
TG
Go to Top of Page

Antonio
Posting Yak Master

168 Posts

Posted - 2005-09-07 : 11:31:14
quote:
Originally posted by TG

Greetings to you!

From Books Online:
quote:
default

Is a default value for the parameter. If a default is defined, the procedure can be executed without specifying a value for that parameter. The default must be a constant or it can be NULL.
You have tried to make the default an expression rather than a constant.


Be One with the Optimizer
TG



Hi TG,

Thanks for the reply.

I have just realised that and modified my code accordingly


datediff(dd, convert(datetime, isnull(cast(@Start_Date as varchar), convert(varchar, dateadd(dd, -30, getdate()), 112)), 112), getdate())
Go to Top of Page
   

- Advertisement -