June 28, 2004 at 1:33 am
can i execute stored procedure from
a stored procedure and get the result set and work accordingly. ??
<a href="http://www.websolsoftware.com"> For IT jobs click here</a>
*Sukhoi*[font="Arial Narrow"][/font]
June 28, 2004 at 1:44 am
Yes,
I have a stored procedure that has a @choice argument. Depending on the value of that argument I execute various stored procedures.
The other thing that is possible is to create a temporary table with the same structure as your results set.
For example, if you inner stored procedure returns and id and description column then you can do the following
CREATE TABLE #tmp (ID INT , Description VARCHAR(50))
INSERT #tmp
EXEC usp_MyProc
Having done this your outer procedure can use #tmp for its own purposes.
June 28, 2004 at 2:04 am
u got a nasty signature dude,
but what does it mean anyway ?
<a href="http://www.websolsoftware.com"> For IT jobs click here</a>
*Sukhoi*[font="Arial Narrow"][/font]
June 28, 2004 at 2:06 am
The signature is allegedly the marriage proposal that the actor, Robert Mitchum, made to an actress whose name escapes me. I think she accepted.
June 29, 2004 at 4:51 am
June 29, 2004 at 1:01 pm
Here is a UDF which return a table:
--START tsql
if exists (select * from sysobjects where id = object_id('dbo.fnc_10_parse_string') and xtype = 'TF')
drop function dbo.fnc_10_parse_string
GO
CREATE FUNCTION dbo.fnc_10_parse_string( @list varchar(8000))
RETURNS @tablevalues TABLE
( itemid int IDENTITY(1,1) , item varchar(8000) )
AS
BEGIN
declare @pos1 int
select @pos1 = 0
declare @startStringLen int
select @startStringLen = LEN(@list + '*') - 1
--This adding the '*' and then substracting 1 char is to get around the LEN
--issue of
--LEN
--Returns the number of characters, rather than the number of bytes, of the given string expression,
-- --->>>> excluding trailing blanks <<<< -----.
DECLARE @P_item varchar(255)
WHILE (@pos1 < @startStringLen)
BEGIN
select @pos1 = @pos1 + 1
SELECT @p_Item = SUBSTRING(@List,@pos1,1)
INSERT INTO @tablevalues
SELECT Item = @p_Item
END
RETURN
END
GO
--end tsql
and how to call it
--
SELECT * FROM
dbo.fnc_10_parse_string('abcdefghijklmnopqrstuvwzyz')
--
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply