Columns used in User defined Table type

PandianS
Posted by PandianS under Sql Server category on | Points: 40 | Views : 3163
1.Creating User defined Table type having Two columns(TypeID, TypeName)
CREATE TYPE MyType
AS TABLE
(
TypeID INT,
TypeName VARCHAR(25)
)
GO
2.Identify Columns used in the User defined Table type(MyType)
SELECT	C.[Name],
TYPE_NAME(C.User_Type_ID) 'Type',
C.Max_Length 'Length',
C.[Precision],
C.Scale FROM sys.table_types T JOIN sys.all_columns C
ON (T.Type_Table_Object_ID = C.[Object_ID])
WHERE T.User_Type_ID = TYPE_ID('MyType')
Result

Name Type Length Precision Scale
TypeID int 4 10 0
TypeName varchar 25 0 0

Comments or Responses

Login to post response