2013-10-02 46 views
2

如何在select語句中使用SQL保留關鍵字,如列名「desc」?如何在列名中使用sql reserve關鍵字

select "desc" from tablename 
+0

的[如何處理看起來像SQL關鍵字的SQL列名?]可能重複(http://stackoverflow.com/questions/285775/how-to-deal-with-sql-column-names -that-look-like-sql-keywords) – LittleBobbyTables

+2

您最好考慮不要使用保留名稱作爲用戶定義的對象名稱... –

+1

[Googling] 30秒(https://www.google.com/search?safe=off&site =&source = hp&q = sql + how + to + use + reserved + words + in + a + statement&oq = sql + how + to + use + reserved + words + in + a + statement)會得到所有這些答案 – LittleBobbyTables

回答

10

使用括號

select [desc] from tablename 
0

根據標準,你可以在這種情況下,前使用delimited identifiers

create table Tdesc("desc" int); 
go 
select "desc" from Tdesc order by "desc" desc; 
相關問題