[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

peter.fredrikson

3/9/2007 12:24:00 PM

I want fo put the result of a function call in a parameter to a stored
procedure without having to use an intermediary variable like:
exec spname @somvariable1, dbo.somefunc1(@somevariable2) --This
returns the error "Incorrect syntax near '.'."

I know I can do it like below, but if there is a way to do it "inline"
I would be very happy if someone told me how!
declare @buf int
select @buf = dbo.somefunc1(@somevariable2)
exec spname @somvariable1, @buf

Peter

2 Answers

Dan Guzman

3/9/2007 12:49:00 PM

0

> I know I can do it like below, but if there is a way to do it "inline"

Nope. Here's what the SQL 2005 Books Online says:

<Excerpt
href="ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/a0b1337d-2059-4872-8c62-3f967d8b170f.htm">

The supplied value must be a constant or a variable; you cannot specify a
function name as a parameter value. Variables can be user-defined or system
variables such as @@spid.

</Excerpt>

--
Hope this helps.

Dan Guzman
SQL Server MVP

<peter.fredrikson@extenda.se> wrote in message
news:1173443057.796682.112990@p10g2000cwp.googlegroups.com...
>I want fo put the result of a function call in a parameter to a stored
> procedure without having to use an intermediary variable like:
> exec spname @somvariable1, dbo.somefunc1(@somevariable2) --This
> returns the error "Incorrect syntax near '.'."
>
> I know I can do it like below, but if there is a way to do it "inline"
> I would be very happy if someone told me how!
> declare @buf int
> select @buf = dbo.somefunc1(@somevariable2)
> exec spname @somvariable1, @buf
>
> Peter
>

peter.fredrikson

3/9/2007 1:01:00 PM

0

Thank you! I missed that one.

On Mar 9, 1:49 pm, "Dan Guzman" <guzma...@nospam-online.sbcglobal.net>
wrote:
> > I know I can do it like below, but if there is a way to do it "inline"
>
> Nope. Here's what the SQL 2005 Books Online says:
>
> <Excerpt
> href="ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/a0b1337d-2059-4872-8c­62-3f967d8b170f.htm">
>
> The supplied value must be a constant or a variable; you cannot specify a
> function name as a parameter value. Variables can be user-defined or system
> variables such as @@spid.
>
> </Excerpt>
>
> --
> Hope this helps.
>
> Dan Guzman
> SQL Server MVP
>
> <peter.fredrik...@extenda.se> wrote in message
>
> news:1173443057.796682.112990@p10g2000cwp.googlegroups.com...
>
>
>
> >I want fo put the result of a function call in a parameter to a stored
> > procedure without having to use an intermediary variable like:
> > exec spname @somvariable1, dbo.somefunc1(@somevariable2) --This
> > returns the error "Incorrect syntax near '.'."
>
> > I know I can do it like below, but if there is a way to do it "inline"
> > I would be very happy if someone told me how!
> > declare @buf int
> > select @buf = dbo.somefunc1(@somevariable2)
> > exec spname @somvariable1, @buf
>
> > Peter- Hide quoted text -
>
> - Show quoted text -