Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 22nd, 2004, 04:16 AM
Authorized User
 
Join Date: Oct 2003
Posts: 89
Thanks: 0
Thanked 0 Times in 0 Posts
Default exec sp within another sp

Hi,

I have a sp that returns a list of customers whose status=5
such as
select customerid from customers where status=5

I want to run a second sp that will call the first sp but will return the cumstomerids that are bigger than 5 for example.

The result could return many rows.

Is there a way of doing it?

Thanks

 
Old December 22nd, 2004, 05:46 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

I only know one way to do this. Your 2nd sp would need to so this:
1. create a temp table to hold the results of the 1st sp
2. run the 1st sp, putting the results into the temp table - you can use the syntax INSERT #temptable EXEC yoursp @param1, ...
3. run a query against the temp table to only return the customers you want.

rgds
Phil





Similar Threads
Thread Thread Starter Forum Replies Last Post
SP Encryption carumuga SQL Server 2005 1 September 20th, 2008 10:30 AM
Oracle SP itvenky Oracle 2 November 23rd, 2006 03:13 AM
sp problem lucian Classic ASP Basics 0 July 9th, 2004 01:52 AM
SP used in a SP Mitch SQL Server 2000 16 October 28th, 2003 12:59 PM
Can a SP run another SP as sa? dbradley SQL Server 2000 0 July 17th, 2003 08:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.