sql - Metadata of Stored Procedure Result Set -


i use sql server 2008.

i want column names , data types of result set of stored proc. how can it? information_schema helpful.

from application can inspect potential result set first issuing set fmtonly on. being phased out in future version of sql server in favor of more robust metadata discovery mechanism. in meantime, best you're going using openquery against loopback server. assumes stored procedure returns 1 result set - if there more one, isn't quite going work.

for example:

exec master.dbo.sp_addlinkedserver      @server     = 'loopback_server',     @srvproduct = '',     @provider   = 'sqloledb',     @datasrc    = @@servername;  select * #foo      openquery(loopback_server, 'exec db_name.dbo.proc_name');  select c.name, t.name, t.max_length, t.precision, t.scale     tempdb.sys.columns c     inner join sys.types t     on c.system_type_id = t.system_type_id     c.[object_id] = object_id('tempdb..#foo');  drop table #foo; 

note assumes aren't using clr udts or alias types.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -