Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 sp_helptext to display procs

Author  Topic 

chrispy
Posting Yak Master

107 Posts

Posted - 2007-07-06 : 09:38:06
I am creating a SP to display some stored procedures using sp_helptext.

That is working fine. What I could use is a way to display the results set returned by the SP without actually running the SP. More or less let the user know what columns would be returned.

Is there anything I can do in SQL to accomplish such?

Thanks!

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2007-07-06 : 09:41:20
I don't think this is possible without actually parsing the DDL of the proc, which is likely more than most are prepared to do. Certainly more than I would undertake.


elsasoft.org
Go to Top of Page

chrispy
Posting Yak Master

107 Posts

Posted - 2007-07-06 : 10:41:26
jezemine,

I think you are right, but I thought it was worth a shot. I was thinking pulling something from the last select statement (they are not complicated SPs) and coming up with a result set that way. Not sure if that is worth it even.

Just thought I would try to see if the experts here knew a better way.

Thanks!
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-07-09 : 03:24:01
I'm pretty sure this has come up before on SQLTeam using OPENQUERY to run the SProc and store the results into a temporary table, or somesuch. There was discussion in that thread about determining the data type of the columns.

Might be worth some searching to see if you can find the thread.

"... using sp_helptext. That is working fine ..."

Note that sp_HelpText will insert line breaks (at column 128 IIRC)

Kristen
Go to Top of Page

chrispy
Posting Yak Master

107 Posts

Posted - 2007-07-09 : 18:03:50
Kristen,
Thanks for the help, I will look into that.

:)
Go to Top of Page

mahesh_bote
Constraint Violating Yak Guru

298 Posts

Posted - 2007-07-10 : 08:33:02
By the way, can anybody tell me, is it possible to store a resultset in variable after SP gets executed?

Thanks in advance,

Mahesh
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-07-10 : 08:48:54
quote:
Originally posted by mahesh_bote

By the way, can anybody tell me, is it possible to store a resultset in variable after SP gets executed?

Thanks in advance,

Mahesh


If the resultset is single value, then use OUTPUT parameter

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-07-10 : 09:29:29
"is it possible to store a resultset in variable after SP gets executed?"

... or store in table:

INSERT INTO dbo.MyTable(Col1, Col2, ...)
EXEC dbo.MySproc @Param1, @Param2, ...

Kristen
Go to Top of Page
   

- Advertisement -