简体   繁体   中英

Getting COLUMN_NAME, DATA_TYPE with SQLPro for MSSQL

I am trying to get the COLUMN_NAME, DATA_TYPE using

SELECT COLUMN_NAME, DATA_TYPE 
FROM dbo.[CORDELACIUTAT Resource Time Registr_]

But I got this error:

Msg 207, Level 16, State 1.
Invalid column name 'COLUMN_NAME'.
Msg 207, Level 16, State 1.
Invalid column name 'DATA_TYPE'. (Line 1)

You should query information_schema.columns view

select column_name, data_type 
from information_schema.columns
where table_name = 'CORDELACIUTAT Resource Time Registr_'

You don't access that data directly from the table. Try this:

select COLUMN_NAME,DATA_TYPE from INFORMATION_SCHEMA.COLUMNS
where TABLE_NAME =[CORDELACIUTAT Resource Time Registr_]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM