如何将 MS SQL Server 的一个数据库中的所有表的所有列名更改为大写?

2021-09-14 00:00:00 sql uppercase sql-server

是否有任何sql语句用于将数据库中所有表的所有列名更改为大写?MS SQL 服务器.

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.

  1. 在下面运行 SQL

  1. 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

  • 复制并执行上面的结果

  • copy and execute the result above

    推荐答案

    如果您将应用程序从 SQL Server 2000 升级到更高版本,并且您正在努力解决 SQL Server 区分大小写问题,我建议您在对数据库进行重大更改之前查看 SQL Server 2000 兼容性设置.

    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

    1. 右键单击数据库并在上下文菜单中选择properties
    2. 转到选项页面
    3. 在从顶部数第三个下拉菜单中.选择兼容级别:SQL Server 2000

    至少那是费时的.

    由于看起来 OP 正在将他的数据库从 SQL Server 2005 升级到 SQL Server 2005 上的新"数据库,因此上述策略可能不是最佳的.

    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.

  • 相关文章