Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2005 > SQL Server 2005
|
SQL Server 2005 General discussion of SQL Server *2005* version only.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2005 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 15th, 2007, 05:17 AM
Authorized User
 
Join Date: Jan 2005
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hossrad
Default EXECUTING A STRING (HELP PLEASE!!)

Dear friends,
i have a problem here that as much as i go through it looks worth.
I have build a dynamic query with a string like below:

CREATE PROCEDURE PROC1
AS
DECLARE @TempQString nvarchar(1000)
SET @TempQString = 'DECLARE @resultvalue int'
SET @TempQString =@TempQString + 'EXEC @resultvalue=[MyStoredProcedure]'
EXEC sp_executesql @TempQString
GO

now in the body of my main stored procedure (PROC1) i want to get the
return value if the [MyStoredProcedure] that was executed through a string!!!!!!!!!!

i've tried to insert the return value in a temp table (#table)
but this also didnt work, cuz out of the string execution my temp table was dropped!! also i cant use a global temp table (##table)
because many users may execute the PROC1 at the same time!!
PLEASE HELP THIS IS VERY IMPORTANT FOR ME

God Bless you,
Hossein
__________________
Be Sure,
-hossrad
 
Old May 15th, 2007, 06:26 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

dear Hossin I donno what exatly u want but I done this like this
but remember MyStoredProcedure will not return value it'll select that
go below:;)


Code:
CREATE PROCEDURE [dbo].[MyStoredProcedure]
AS
...
SELECT 111
GO
***************************

CREATE PROCEDURE PROC1
AS
CREATE TABLE #A (ret int)

DECLARE @TempQString nvarchar(1000)
DECLARE @resultvalue int
SET @TempQString ='INSERT INTO #A EXEC [MyStoredProcedure]'
EXEC sp_executesql @TempQString
SELECT @resultvalue = Ret FROM #A
DROP TABLE #A
RETURN @resultvalue
GO
& then run this

Code:
declare @a int
EXEC @a = PROC1
SELECT @A
God bless u too, GUGUL MAGULI

HTH:D

Always:),
Hovik Melkomian.





Similar Threads
Thread Thread Starter Forum Replies Last Post
EXECUTING A STRING (HELP PLEASE!!) hossrad SQL Server 2000 1 May 15th, 2007 07:37 AM
executing a commnad stored in a string... elladi Javascript How-To 1 December 22nd, 2004 01:52 PM
executing 2 datareaders msrnivas .NET Web Services 2 January 8th, 2004 08:15 AM
Executing from memory Knik DerMuf Beginning VB 6 4 July 10th, 2003 07:49 AM





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