Where do I look in Microsof开发者_C百科t SQL Server system tables to find info about the parameters a builtin stored procedure or function takes?
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.
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
精彩评论