Tags: create, exec, output, procedure, programming, ricksean, similar, sp1, sql, stored, todaysummary, varchar, variable

Output Variable from Stored Procedure

On Programmer » SQL

3,097 words with 3 Comments; publish: Wed, 28 May 2008 23:57:00 GMT; (200136.72, « »)

This questions is very similar to the one posted earlier by RickSean. thank

you

create procedure sp1

.sql.todaysummary.com.sql Varchar(2000)

AS

EXEC sp_executesql .sql.todaysummary.com.sql

RETURN

create procedure sp2

AS

EXEC sp1 'select count(*) from Table1'

-- Here, I want to get the record count from sp1 and assign to a

variable

.sql.todaysummary.com.var1 = recordcount

print .sql.todaysummary.com.var1

All Comments

Leave a comment...

  • 3 Comments
    • http://sqlserver2000.databases.aspfaq.com/how-do-i-get-the-result-of-dynamic-sql-into-a-variable.html

      --

      Aaron Bertrand

      SQL Server MVP

      http://www.sqlblog.com/

      http://www.aspfaq.com/5006

      "Ryan" <Ryan.sql.todaysummary.com.discussions.microsoft.com> wrote in message

      news:762BE271-34C4-4640-8814-E5870F8F0EE1.sql.todaysummary.com.microsoft.com...

      > This questions is very similar to the one posted earlier by RickSean.

      > thank

      > you

      > create procedure sp1

      > .sql.todaysummary.com.sql Varchar(2000)

      > AS

      > EXEC sp_executesql .sql.todaysummary.com.sql

      > RETURN

      > create procedure sp2

      > AS

      > EXEC sp1 'select count(*) from Table1'

      > -- Here, I want to get the record count from sp1 and assign to a

      > variable

      > .sql.todaysummary.com.var1 = recordcount

      > print .sql.todaysummary.com.var1

      #1; Wed, 28 May 2008 23:58:00 GMT
    • I've already tried the link but did get what I was looking for.

      "Aaron Bertrand [SQL Server MVP]" wrote:

      > http://sqlserver2000.databases.aspfaq.com/how-do-i-get-the-result-of-dynamic-sql-into-a-variable.html

      > --

      > Aaron Bertrand

      > SQL Server MVP

      > http://www.sqlblog.com/

      > http://www.aspfaq.com/5006

      > "Ryan" <Ryan.sql.todaysummary.com.discussions.microsoft.com> wrote in message

      > news:762BE271-34C4-4640-8814-E5870F8F0EE1.sql.todaysummary.com.microsoft.com...

      > > This questions is very similar to the one posted earlier by RickSean.

      > > thank

      > > you

      > > create procedure sp1

      > > .sql.todaysummary.com.sql Varchar(2000)

      > > AS

      > > EXEC sp_executesql .sql.todaysummary.com.sql

      > > RETURN

      > >

      > > create procedure sp2

      > > AS

      > > EXEC sp1 'select count(*) from Table1'

      > > -- Here, I want to get the record count from sp1 and assign to a

      > > variable

      > > .sql.todaysummary.com.var1 = recordcount

      > > print .sql.todaysummary.com.var1

      >

      >

      #2; Wed, 28 May 2008 23:59:00 GMT
    • > I've already tried the link but did get what I was looking for.

      Ok. <shrug>

      Maybe you could explain in more detail the gap between what was provided and

      what is required.

      --

      Aaron Bertrand

      SQL Server MVP

      http://www.sqlblog.com/

      http://www.aspfaq.com/5006

      #3; Thu, 29 May 2008 00:00:00 GMT