Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Execute a procedure from within a SQL select
Message
From
29/11/2005 16:26:52
Keith Payne
Technical Marketing Solutions
Florida, United States
 
General information
Forum:
Microsoft SQL Server
Category:
Other
Miscellaneous
Thread ID:
01072912
Message ID:
01073015
Views:
22
>>Hi, Mike,
>>
>>Any reason you can't turn that stored procedure into a UDF?
>>
>>Kevin
>
>There is already fairly complicated working stored procedure that handles this process that we would like to use and not duplicate.

Mike,
.
.
.
if exists(select [name] from tempdb..sysobjects where [name] = '#MyResults')
DROP TABLE #MyResults

CREATE TABLE #MyResults (
ResultID int NOT NULL CLUSTERED PRIMARY KEY IDENTITY (1,1),
MyResult varchar(20)
)

INSERT INTO #MyResults
EXEC MyStoredProcedure @p1 = 'Hello', @p2 = 'World'

SELECT * FROM #MyResults

if exists(select [name] from tempdb..sysobjects where [name] = '#MyResults')
DROP TABLE #MyResults
.
.
.
GO
CREATE PROCEDURE MyStoredProcedure (
@p1 varchar(10),
@p2 varchar(10)
)
AS
SELECT @p1 + ' ' + @p2 as MyResult
GO
Previous
Reply
Map
View

Click here to load this message in the networking platform