Two statements in 1 EXEC statement

Two statements in 1 EXEC statement

Post by Eric Sabi » Thu, 14 Feb 2002 22:02:35



Is this possible?

I have a SP that scrolls through databases via a cursor.  Because the
database name changes, I need to place the statement in an EXEC()
statement rather than leave it outside.  But, I also want to store a
variable with a result in the statement.  See below:


changes




yada..'



have it execute too?

Eric

 
 
 

Two statements in 1 EXEC statement

Post by Steve Kas » Thu, 14 Feb 2002 23:07:26


Eric,

  Here is an example of how to use sp_executesql with an output
parameter:










Steve Kass
Drew University


> Is this possible?

> I have a SP that scrolls through databases via a cursor.  Because the
> database name changes, I need to place the statement in an EXEC()
> statement rather than leave it outside.  But, I also want to store a
> variable with a result in the statement.  See below:


> changes




> yada..'

> If I tried running this, I would get "Must declare the variable


> have it execute too?

> Eric


 
 
 

Two statements in 1 EXEC statement

Post by Dinesh T » Thu, 14 Feb 2002 23:51:24


Eric,

Refer
http://support.microsoft.com/default.aspx?scid=KB;EN-US;q262499&ID=KB...
q262499

Dinesh.


> Is this possible?

> I have a SP that scrolls through databases via a cursor.  Because the
> database name changes, I need to place the statement in an EXEC()
> statement rather than leave it outside.  But, I also want to store a
> variable with a result in the statement.  See below:


> changes




> yada..'

> If I tried running this, I would get "Must declare the variable


> have it execute too?

> Eric

 
 
 

Two statements in 1 EXEC statement

Post by Eric Sabin » Fri, 15 Feb 2002 11:14:59


Thanks all three of you.  This is exactly what I needed.

Eric


Quote:> Eric,

> Refer

http://support.microsoft.com/default.aspx?scid=KB;EN-US;q262499&ID=KB...
> q262499

> Dinesh.



> > Is this possible?

> > I have a SP that scrolls through databases via a cursor.  Because the
> > database name changes, I need to place the statement in an EXEC()
> > statement rather than leave it outside.  But, I also want to store a
> > variable with a result in the statement.  See below:


> > changes




> > yada..'

> > If I tried running this, I would get "Must declare the variable


> > have it execute too?

> > Eric