Thursday, May 12, 2011

To Find Parameter Data Type Size

CREATE PROC [dbo].[PARAMETERS_TYPES_SIZES]
AS
BEGIN
            SELECT PR.NAME,PA.NAME,TY.NAME+
                                    CASE WHEN TY.NAME IN ('int','smallint','bigint','bit','datetime','money','tinyint') 
                                    THEN '' 
                                    ELSE '('+cast(PA.max_length as varchar(100))+')' END as SIZE
            FROM SYS.PROCEDURES PR
                        JOIN  SYS.PARAMETERS PA
            ON PR.OBJECT_ID=PA.OBJECT_ID
                        JOIN SYS.TYPES TY
            ON PA.USER_TYPE_ID=TY.USER_TYPE_ID
END
exec  PARAMETERS_TYPES_SIZES

output:
NAME                 NAME                         SIZE

Sp_Proc               @parameterName        Varchar(100)

No comments:

Post a Comment