get basic SQL Server table structure information

后端 未结 6 1992
心在旅途
心在旅途 2021-02-05 04:21

I can get the number of columns in an SQL Server database with this:

SELECT COUNT(*)
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = \'Address\'
6条回答
  •  迷失自我
    2021-02-05 04:38

    Instead of using count(*) you can SELECT * and you will return all of the details that you want including data_type:

    SELECT *
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE table_name = 'Address'
    

    MSDN Docs on INFORMATION_SCHEMA.COLUMNS

提交回复
热议问题