Developing Matt

My Technical Journal

Calling a stored proc (within a stored proc)

with 2 comments

When a programmer migrates into t-sql logic they start asking questions like ‘how do you call a stored procedure from another stored procedure and use the resultset?’  So one way is to specify an output parameter.

create procedure dummyReturnLastName
@FullName varchar
@LastName varchar(15) output
@lastname = substring(@fullname, charindex(‘ ‘,@fullname), len(@fullname)-charindex(‘ ‘,@fullname)+1)

And you call it with

declare @lastname varchar(15)
dummyReturnLastName ‘matt clingan’,@lastname output


Written by matt

July 3, 2007 at 6:02 am

Posted in T-Sql

2 Responses

Subscribe to comments with RSS.

  1. […] I discussed how to call a stored procedure within a stored procedure.

  2. another way to do this is by using table variables

    declare @tbl table (strname varchar(200))

    insert into @tbl
    execute dummyReturnLastName ‘matt clingan’,@lastname

    select * from @tbl


    August 1, 2008 at 3:28 pm

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: