如何返回表的列名?

2022-01-31 00:00:00 sql tsql sql-server

如何使用 SQL Server 2008 返回表的列名?即一个表包含这些列 - id、名称、地址、国家,我想将这些作为数据返回.

How would I return the column names of a table using SQL Server 2008? i.e. a table contains these columns- id, name, address, country and I want to return these as data.

推荐答案

不知道2008版有没有更简单的方法.

Not sure if there is an easier way in 2008 version.

USE [Database Name]
SELECT COLUMN_NAME,* 
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'YourTableName' AND TABLE_SCHEMA='YourSchemaName'

相关文章