tags:

views:

37

answers:

2

Where do I look in Microsoft SQL Server system tables to find info about the parameters a builtin stored procedure or function takes?

+1  A: 

Looks like a join on sys.system_objects and sys.system_paramters will do it. This should get you started:

SELECT ob.object_id, ob.name, ob.is_ms_shipped, ob.type_desc, pa.*
 from sys.system_objects ob
  inner join sys.all_parameters pa
   on pa.object_id = ob.object_id

Reset with the columns you're interested in and you should be good.

Make it a left outer join to pick up objects that have no parameters.

Philip Kelley
Works like a charm. Thanks. I filtered it using a WHERE clause.
John K
A: 

Here is sql Function that returns parameter info of a given routine

    ALTER     Function [dbo].[ftRoutineSchema](@RoutineName varchar(200)) returns table as return 
--declare @routineName varchar(100);select @routineName='ftDetailsOfLogin'
SELECT   ColumnName=Case Is_Result
                                    When 'YES' then '@RC'
                                  else Parameter_Name
                            end
            ,DataType= case Data_Type
                            When  'DECIMAL' then 'Decimal('+convert(varchar,Numeric_precision)+','+Convert(varchar,Numeric_scale)+')'
                            When  'numeric' then 'Decimal('+convert(varchar,Numeric_precision)+','+Convert(varchar,Numeric_scale)+')'
                            when 'varchar' then 'Varchar('+Convert(varchar,Character_maximum_length)+')'
                            ELSE dATA_TYPE      
                          end
            ,ColumnOrder=Ordinal_Position   
            ,Direction =Case Parameter_Mode
                                when 'INOUT' then 'Out'
                                else Parameter_Mode
                            end

 FROM  --INFORMATION_SCHEMA.ROUTINE_cOLUMNS
         Information_schema.Parameters  
--WHERE TABLE_NAME=@routineName --order by columnorder
  Where Specific_name=@ROUTINEnAME
TonyP