Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > Reporting Services
|
Reporting Services SQL Server Reporting Services. Please specify which version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Reporting Services 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 May 24th, 2007, 08:31 AM
Authorized User
 
Join Date: Nov 2006
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default Stored procedure problem

Hi
my problem is related with procedure as well as function. Actually, I want to get return value from proc1 to proc2. For that I am giving u a very simple examle in steps....

Step 1: I have to create a proc sp1

create proc sp1 @p1 int,@p2 int
as
return @p1 * @p2

Step 2: Now i execute sp1 and created proc sp2

create proc sp2
as
declare @x int
set @x = sp1 5,6
print @x

or

create proc sp2
as
declare @x int
declare @y int
declare @z int
set @y=4
set @z=6
set @x = sp1 @y,@z
print @x


Step 3: I want to run that proc sp2
but it gives error : Incorrect syntax near '5'.

Pls Solve this problem.

Note : Here is not allowed to use OUTPUT parmameter

Thanks in advance
Kumar Ashish
[email protected]
__________________
Thanks
Kumar Ashish
[email protected]
 
Old May 29th, 2007, 01:25 AM
Registered User
 
Join Date: May 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think you can't do what you are trying to do with a stored procedure.

SPs return rowset as a result set, which actually is not easy to use in a later stages of the procedure. It can be done, and involves using the openrowset TSQL function, but it's usually not necessary and the overhead of using it is probably enough not to try.

The SPs result sets are on the other hand easy to use from other clients, it's just TSQL that has problems with it.

Your options are to make sp1 return an output paramter. The syntax would be:

create proc sp1 @p1 int,@p2 int, @p3 int output
as
set @p3 = @p1 * @p2

And then in sp2:

create proc sp2
as
declare @x int
declare @y int
declare @z int
set @y=4
set @z=6
execute sp1 @y, @z, @x output
print @x

You do have another option and that's to make sp1 a FUNCTION, not a PROC.

Regards,
Palli





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with stored procedure analuz ADO.NET 1 July 18th, 2007 08:33 AM
Problem in stored procedure hkec SQL Language 1 October 6th, 2006 02:29 PM
Stored Procedure Problem kwilliams SQL Server 2000 7 June 23rd, 2006 03:03 PM
Stored procedure problem dkspivey SQL Language 2 February 6th, 2006 01:44 PM
Stored Procedure Problem brettdavis4 ASP.NET 1.0 and 1.1 Basics 7 November 3rd, 2003 09:46 PM





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