SQL SERVER gets the object (stored procedure, function, and so on) parameter information

Source: Internet
Author: User
Tags joins

CREATE PROCEDURE [Common]. [Procloadfunctionparameters]

@inObjectName sysname

As

BEGIN

SELECT sp.object_id as FunctionId,

Sp.name as FunctionName,

(case is param.is_output = 1 Then ' output ' ELSE ' in ' END) as Paramtype,

ISNULL (Param.name, ') as ParamName,

ISNULL (Usrt.name, ") as [DataType],

ISNULL (Baset.name, ") as [SystemType],

CAST (case if Baset.name is NULL then 0

When baset.name in (' nchar ', ' nvarchar ')

Param.max_length <>-1

Then PARAM.MAX_LENGTH/2

ELSE Param.max_length

END as INT) as [Length],

ISNULL (parameter_id, 0) as SortId,

' as Paramreamrk

From sys.objects as SP

INNER JOIN sys.schemas b on sp.schema_id = b.schema_id

Left OUTER joins Sys.all_parameters as param on param.object_id = sp.object_id

Left OUTER joins Sys.types as usrt on usrt.user_type_id = param.user_type_id

Left OUTER joins Sys.types as Baset on (baset.user_type_id = param.system_type_id

and baset.user_type_id = baset.system_type_id

)

OR ((baset.system_type_id = param.system_type_id)

and (baset.user_type_id = param.user_type_id)

and (baset.is_user_defined = 0)

and (Baset.is_assembly_type = 1)

)

Left OUTER joins sys.extended_properties E on sp.object_id = e.major_id

WHERE sp.object_id = object_id (@inObjectName)

and Sp.type in (' FN ', ' IF ', ' TF ', ' P ')

and ISNULL (sp.is_ms_shipped, 0) = 0

and ISNULL (E.name, ') <> ' Microsoft_database_tools_support '

ORDER by Sp.name,

PARAM.PARAMETER_ID ASC;

END;

GO

SQL SERVER gets the object (stored procedure, function, and so on) parameter information

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.