問題描述
是否有任何sql語句用于將數(shù)據(jù)庫中所有表的所有列名更改為大寫?MS SQL 服務(wù)器.
is there any sql statement used to change all column name to UPPER CASE for all tables in database? MS SQL Server.
我有一個 sql 來做這個,但不確定它是否正確.
I got a sql to do that, but not sure whether it`s correct.
在下面運行 SQL
run SQL below
select 'exec sp_rename '''+b.name+'.'+a.name+''','''+UPPER(a.name)+''',''column'''
from syscolumns a, sysobjects b
where a.id=b.id and b.type='U'
order by b.name
復(fù)制并執(zhí)行上面的結(jié)果
copy and execute the result above
推薦答案
如果您將應(yīng)用程序從 SQL Server 2000 升級到更高版本,并且您正在努力解決 SQL Server 區(qū)分大小寫問題,我建議您在對數(shù)據(jù)庫進行重大更改之前查看 SQL Server 2000 兼容性設(shè)置.
If you are upgrading an application from SQL Server 2000 to a later edition, and you are struggeling with SQL Server case sensitivity, I would suggest you look into the SQL Server 2000 compatibility setting before you do drastic changes to the database.
在 SQL Server 2008 Management Studio 中
In SQL Server 2008 Management Studio
- 右鍵單擊數(shù)據(jù)庫并在上下文菜單中選擇
properties
- 轉(zhuǎn)到
選項
頁面 - 在從頂部數(shù)第三個下拉菜單中.選擇
兼容級別:SQL Server 2000
至少那是費時的.
由于看起來 OP 正在將他的數(shù)據(jù)庫從 SQL Server 2005 升級到 SQL Server 2005 上的新"數(shù)據(jù)庫,因此上述策略可能不是最佳的.
Since it appears that OP is upgrading his database from SQL Server 2005 to a "new" database on SQL Server 2005, the above strategy might not be optimal.
這篇關(guān)于如何將 MS SQL Server 的一個數(shù)據(jù)庫中的所有表的所有列名更改為大寫?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!