Groups | Blog | Home
all groups > sql server programming > august 2006 >

sql server programming : Stored Procedure Column schema


Patrick
8/5/2006 9:35:34 PM
Hello all!
Can one dev help another? Is there any way to get the column schema from a
stored procedure without calling it with parameters in slq server 2000? I
just want to know the columns it returns.

Many thanks,
Sincerely,
Patrick

Tom Cooper
8/5/2006 10:19:24 PM
No, you either have to look at the code of the stored proc or run the stored
proc. It would be very difficult to write a generalized piece of code to
examine a stored proc and return all possible results because stored procs
can do almost anything. Like return multiple result sets or return
different result sets depending on various factors. For example, the
following will return a different set of columns in its result set depending
on the time of day you run it.

Use pubs
go
Create Procedure VeryBadProc As
If DatePart(hour,GetDate()) >= 12
Select * from sysobjects
Else
Select * From syscolumns
go
exec VeryBadProc
Drop Procedure VeryBadProc

Tom

[quoted text, click to view]

Patrick
8/5/2006 11:00:25 PM
Thanks Tom. That is a VERY good point. Of course my procedures do not do
that, but what you described would be an impossible challenge to the MS
devs.

Thanks again,
Sincerely,
Patrick

[quoted text, click to view]

AddThis Social Bookmark Button