重命名列返回错误

编程入门 行业动态 更新时间:2024-10-25 03:19:45
本文介绍了重命名列返回错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我尝试使用此过程来重命名 SQL Server 中名称错误的列.生成的语句似乎正确:EXEC sp_rename '[TBL_TAXREPORTtestxxx].["InsertedOn"]', 'InsertedOn', 'COLUMN'

I tried using this procedure to rename badly named columns in SQL Server. The generated statement seems correct: EXEC sp_rename '[TBL_TAXREPORTtestxxx].["InsertedOn"]', 'InsertedOn', 'COLUMN'

但是这给了我以下错误:

however that gives me the following error:

Msg 15248, Level 11, State 1, Procedure sp_rename, Line 266 Either the parameter @objname is ambiguous or the claimed @objtype (COLUMN) is wrong.

有什么线索吗?

推荐答案

选项 1: 您可以尝试检查是否在正确的数据库中运行查询.

Option 1: You can try to check if you are running the query in the correct database.

选项 2:如果是,那么试试这个:

Option 2: If yes then try this:

EXEC sp_rename @objname = 'TBL_TAXREPORTtestxxx."[InsertedOn]"', --or @objname = 'TBL_TAXREPORTtestxxx."InsertedOn"' @newname = 'InsertedOn', @objtype = 'COLUMN'

选项 3:如果上述方法也失败,那么您可以尝试创建一个名称正确的新表,并将数据从现有表复制到新表并删除前一个表.最后重命名表.

Option 3: If the above also fails then you can try to create a new table with all the names correct and copy the data from the existing table to the new table and drop the previous one. And finally rename the table.

选项 4: 正如 Gordon 在评论中所说,您可能还想检查架构.

Option 4: As Gordon has said in comments, you might also want to check for schema.

EXEC sp_rename @objname = '[dbo].TBL_TAXREPORTtestxxx."[InsertedOn]"', @newname = 'InsertedOn', @objtype = 'COLUMN'

更多推荐

重命名列返回错误

本文发布于:2023-10-16 16:04:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1498058.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重命名   错误

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!