0

我刚刚在 tsql 中创建了一个表,但现在我希望能够获得该表的定义,例如列名,它是 int 还是 nvarchar 还是它的任何参数,是否为 null 等等。 tsql 查询是什么?

4

2 回答 2

0

您可以为此查询架构,如下所示:

SELECT 
   ORDINAL_POSITION,
   DATA_TYPE,
   CHARACTER_MAXIMUM_LENGTH,
   IS_NULLABLE,
   COLUMN_DEFAULT
FROM   
   INFORMATION_SCHEMA.COLUMNS 
WHERE   
   TABLE_NAME = 'Product' 
ORDER BY 
   ORDINAL_POSITION ASC; 
于 2013-08-16T13:16:18.307 回答
0
SELECT 
    ColumnName  = C.Name
,   ColumnSeq   = C.column_id
,   DataType    = T.name
,   MaxLength   = C.max_length
,   Percision   = C.precision
,   Scale       = c.scale
,   IsNullable  = C.Is_nullable
,   IsIdentiy   = C.Is_identity
,   Colation    = c.collation_name
FROM sys.Columns C
JOIN sys.Types T ON T.System_Type_id = C.System_Type_id
where c.object_id = object_id('dbo.product')
order by c.column_id
于 2013-08-19T19:18:46.797 回答