June 1, 2011 at 5:57 am
Hello All,
I would like to know how to get the stored procedures
parameters along with it's types ??
create proc spstore
as
@ID INt,
@EmpName varchar(25)
Begin
insert into (-----)
ENd
I want to retrive the parameters ,Type
ie 1> @ID Int
2> @EmpName varchar(25)
June 1, 2011 at 6:30 am
They should be in sys.columns. Query sys.procedures join sys.columns
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
June 1, 2011 at 7:39 am
Actually, you need to query sys.parameters...
SELECT SchemaName = ss.name,
ObjectName = so.name,
ParameterName = sp.name,
DataTypeName = st.name + CASE WHEN st.name LIKE '%char'
THEN '(' + CASE WHEN sp.max_length = -1
THEN 'max'
ELSE CONVERT(VARCHAR(10), sp.max_length)
END + ')'
WHEN st.name IN ('decimal','numeric')
THEN '(' + CONVERT(VARCHAR(10), sp.scale) + ',' + CONVERT(VARCHAR(10), sp.precision) + ')'
ELSE ''
END,
sp.scale,
sp.precision,
sp.parameter_id, sp.*
FROM sys.parameters sp
JOIN sys.objects so
ON sp.object_id = so.object_id
JOIN sys.schemas ss
ON so.schema_id = ss.schema_id
JOIN sys.types st
ON sp.user_type_id = st.user_type_id
ORDER BY SchemaName, ObjectName, sp.parameter_id;
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
June 1, 2011 at 7:57 am
Or you could keep it ISO, and avoid all those joins, with INFORMATION_SCHEMA.PARAMETERS.
John
June 1, 2011 at 11:37 pm
Thank you very much it had solved my issue
June 3, 2011 at 12:05 am
Please use this.
SP_HELP 'Procedure Name'
June 3, 2011 at 12:05 am
tharuraju (6/1/2011)
Hello All,I would like to know how to get the stored procedures
parameters along with it's types ??
create proc spstore
as
@ID INt,
@EmpName varchar(25)
Begin
insert into (-----)
ENd
I want to retrive the parameters ,Type
ie 1> @ID Int
2> @EmpName varchar(25)
June 15, 2011 at 5:32 am
June 15, 2011 at 6:45 am
Jayanth_Kurup (6/15/2011)
Whats wrong with using sp_help 'proc name' ?
It returns more than one result set so it's difficult to use programatically. If you compare the SQL behind the view 'INFORMATION_SCHEMA.PARAMETERS' and the SQL executed by sp_help to return the parameters, I'd wager that it's very similar.
John
June 20, 2011 at 1:25 am
Viewing 10 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply