sql server - Using function as a parameter when executing a stored procedure? -
this question has answer here:
i'm testing stored procedure , wanted submit 'getdate()' function in place of parameter:
declare @return_value int exec @return_value = my_store procedure @myid = 1, @mydatefield = getdate() select 'return value' = @return_value go
sql server 2005 complains following error:
incorrect syntax near ')'.
anybody care shed light on matter?
per msdn
execute stored procedure or function [ { exec | execute } ] { [ @return_status = ] { module_name [ ;number ] | @module_name_var } [ [ @parameter = ] { value | @variable [ output ] | [ default ] } ] [ ,...n ] [ recompile ] } [;] execute character string { exec | execute } ( { @string_variable | [ n ]'tsql_string' } [ + ...n ] ) [ { login | user } = ' name ' ] [;] execute pass-through command against linked server { exec | execute } ( { @string_variable | [ n ] 'command_string [ ? ]' } [ + ...n ] [ { , { value | @variable [ output ] } } [ ...n ] ] ) [ { login | user } = ' name ' ] [ @ linked_server_name ] [;]
notice @parameter can either specify value or variable or specify default. got set value of variable getdate() (as others have specified) , use variable.
hth
Comments
Post a Comment