evaluating statement within a parameter for stored procedure
Is is possible to do something like this? (I don't know what the
proper terminology is... evaluating statement inline??)
exec pr_foo [at] param = 'a' + 'b'
exec pr_foo [at] param = getdate()
I wasn't able to get this to work. I know I can use a local variable
do all the manipulation, then pass the local variable, but I was
wondering if there was a way to do it inline.
Re: evaluating statement within a parameter for stored procedure
bucky3 (bucky3 [at] mail.com) writes:
> Is is possible to do something like this? (I don't know what the
> proper terminology is... evaluating statement inline??)
>
> exec pr_foo [at] param = 'a' + 'b'
> exec pr_foo [at] param = getdate()
>
> I wasn't able to get this to work. I know I can use a local variable
> do all the manipulation, then pass the local variable, but I was
> wondering if there was a way to do it inline.
No, you cannot pass expressions as actual parameters in T-SQL. Only
constants and variables.
--
Erland Sommarskog, SQL Server MVP, esquel [at] sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downlo ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books .mspx
Re: evaluating statement within a parameter for stored procedure
No, T-SQL is a simple one-pass compiler with strong typing. Your
parameters have to be constants or variables and at least cast-able to
the declared data type.
Re: evaluating statement within a parameter for stored procedure
On Apr 3, 1:29 pm, Erland Sommarskog <esq... [at] sommarskog.se> wrote:
> No, you cannot pass expressions as actual parameters in T-SQL. Only
> constants and variables.
OK thanks.