Script like below:
-- get table or view column
DECLARE @TableViewName NVARCHAR(128)
SET @TableViewName = N'testinvoice' -- table name
SELECT b.name AS ColumnName
,c.name AS DataType
,b.max_length AS Length
,b.precision as DataTypeprecision
,b.scale as DataTypescale
,c.Precision AS SystemMaxPrecision
,c.Scale AS SystemMaxScale
,d.value AS Description
FROM sys.all_objects a
INNER JOIN sys.all_columns b ON a.object_id = b.object_id
INNER JOIN sys.types c ON b.user_type_id = c.user_type_id
LEFT JOIN sys.extended_properties d ON a.object_id = d.major_id
AND b.column_id = d.minor_id
AND d.name = 'MS_Description'
WHERE a.Name = @TableViewName
AND a.type IN (
'U'
,'V'
)
Share on Twitter
Share on Facebook
SQL Server Analytics Service 1
SEO(1) Github(2) Title Tag(2) ML(1) 李宏毅(1) SQL Server(18) Tempdb(1) SSMS(1) Windows(1) 自我成長(2) Excel(1) python Flask(1) python(5) Flask(2)
Max Chen (159)