Describe table structure

前端 未结 13 2197
北恋
北恋 2020-12-23 15:37

Which query will give the table structure with column definitions in SQL?

13条回答
  •  礼貌的吻别
    2020-12-23 16:20

    Sql server

    DECLARE @tableName nvarchar(100)
    SET @tableName = N'members' -- change with table name
    SELECT
        [column].*,
        COLUMNPROPERTY(object_id([column].[TABLE_NAME]), [column].[COLUMN_NAME], 'IsIdentity') AS [identity]
    FROM 
        INFORMATION_SCHEMA.COLUMNS [column] 
    WHERE
        [column].[Table_Name] = @tableName
    

提交回复
热议问题