简体   繁体   中英

How can I fetch non-english column names from a table in SQL Server 2008?

I have created an items_table. The columns' name of this table are ਸੋਯਾਬੀਨ and ਕਨ੍ਨੀ , which are in language other than english. I successfully created the columns using
alter table item_table add "+item.Text+" Nvarchar(50);

where the non-english column name was entered in a textbox on UI. but now in next step i want to fetch the column names from this table and add them as an item in a combobox in ac# app. I want to know the query which can fetch the non-english column names. i am currently using the query-->> select * from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME=N'item_table'

and what it returns is the name of my database.

Based on little info you posted, I assume you're looking for INFORMATION_SCHEMA .

SELECT * FROM INFORMATION_SCHEMA.COLUMNS

or

SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME=N'MyTable'

I don't know all of the rules but SQL Server requires you add additional encapsulation for non-English column names. It appears to be based on code page; I hope someone else can add a reference that's clearer.

This works on SQL Server 2008 (express):

SELECT [ वाabcÖ432ÖवाÖ ], [ [[]]न्यÖवा!223]]Ö ] FROM [dbo].[ वाabcÖ432ÖवाÖ ]

[ // Encapsulate the column
    [ // Escape the first set of characters
        [[]न्यÖवा!223]
    ]
    Ö
]

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