|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
getdate() as a parameter to a stored procedureAssume aStoredProcedure accepts one parameter, a datetime. I would like to do
this: exec sStoredProcedure @parameter1 = getdate() ....to call it with the current date time, but this results in a syntax error. Is there any way I can do the above in one statement (i.e. without declaring and assigning a variable first)? You can't use a function as a parameter value. You can declare the
variable, or you can change the stored procedure so that if you leave the parameter out (or hardcode some token value like 1900-01-01), it populates the value inline with the value of GETDATE(). Show quote "Ken" <K**@discussions.microsoft.com> wrote in message news:A88FD2A1-1F89-4ECA-AA64-3BF23462CDCB@microsoft.com... > Assume aStoredProcedure accepts one parameter, a datetime. I would like to > do > this: > > exec sStoredProcedure @parameter1 = getdate() > > ...to call it with the current date time, but this results in a syntax > error. Is there any way I can do the above in one statement (i.e. without > declaring and assigning a variable first)? DECLARE @Variable DateTime
SET @Variable = GetDate() exec sStoredProcedure @parameter1 = @Variable You cannot use a function as a parameter value. -- Show quoteGregory A. Beamer MVP; MCP: +I, SE, SD, DBA *************************** Think Outside the Box! *************************** "Ken" wrote: > Assume aStoredProcedure accepts one parameter, a datetime. I would like to do > this: > > exec sStoredProcedure @parameter1 = getdate() > > ...to call it with the current date time, but this results in a syntax > error. Is there any way I can do the above in one statement (i.e. without > declaring and assigning a variable first)? |
|||||||||||||||||||||||