HUH函数
USE TEMPDBGOIF OBJECT_ID('TB') IS NOT NULL DROP TABLE TBGOCREATE TABLE TB(COL1 INT,COL2 INT,COL3 INT,COL4 INT)GODECLARE @SQL VARCHAR(MAX)SELECT @SQL='SELECT '+NAME+' FROM TB'FROM SYS.COLUMNSWHERE OBJECT_ID=OBJECT_ID('TB')AND COLUMN_ID=3EXEC (@SQL)