- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用以下带有 sp_rename
的 SQL 命令来重命名列。
USE MYSYS;
GO
EXEC sp_rename 'MYSYS.SYSDetails.AssetName', 'AssetTypeName', 'COLUMN';
GO
但它导致了错误:
Msg 15248, Level 11, State 1, Procedure sp_rename, Line 238
Either the parameter @objname is ambiguous or the claimed @objtype (COLUMN) is wrong.
请建议如何使用 sp_rename
重命名列。
[我正在使用的这个命令在 Microsoft Technet 中找到]
最佳答案
试试这个:
USE MYSYS;
GO
EXEC sp_rename 'SYSDetails.AssetName', 'AssetTypeName', 'COLUMN';
GO
sp_rename (Transact-SQL) (msdn):
[ @objname = ] 'object_name'
Is the current qualified or nonqualified name of the user object or data type. If the object to be renamed is a column in a table, object_name must be in the form table.column or schema.table.column. If the object to be renamed is an index, object_name must be in the form table.index or schema.table.index. If the object to be renamed is a constraint, object_name must be in the form schema.constraint.
Quotation marks are only necessary if a qualified object is specified. If a fully qualified name, including a database name, is provided, the database name must be the name of the current database. object_name is nvarchar(776), with no default.
具有完全限定名称的语法:
USE Database
GO
EXEC sp_rename 'Database.Schema.TableName.ColumnName', 'NewColumnName', 'COLUMN';
GO
如果您希望在对象名称中使用完全限定名称,您还应该指定架构。因此,如果您的 SYSDetails 表位于 dbo 架构中,则以下代码应该适合您:
USE MYSYS;
GO
EXEC sp_rename 'MYSYS.dbo.SYSDetails.AssetName', 'AssetTypeName', 'COLUMN';
GO
关于sql - sp_rename 与列有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20440347/
是否有与 sp_rename 等效的 DB2 v9.1? 最佳答案 这取决于对象。 对于表和索引,您可以使用 RENAME sql语句。 如果要重命名列,可以使用 ALTER TABLE ... RE
我正在使用以下带有 sp_rename 的 SQL 命令来重命名列。 USE MYSYS; GO EXEC sp_rename 'MYSYS.SYSDetails.AssetName', 'Asset
我有一个名为 patient 的表,它包含一个名为 IdP 的列。 我正在尝试将 IdP 重命名为 ID这段代码: EXECUTE sp_RENAME 'patient.IdP' , 'ID', 'C
我正在尝试运行以下命令: EXEC sp_rename '"database_name"."table_name"."old_column_name"', 'new_column_name'; 但是我
我在 sql server 2012 中有一个需要重命名的 sql 表。我知道在其他数据库系统中,执行此操作的方法如下: ALTER TABLE table_name RENAME TO new_
我通过 sp_RENAME (SQL SERVER 2008) 重命名了该表 sp_RENAME 'dbname.scname.oldtblname' 'dbname.scname.newtblnam
ALTER TABLE [TEMP] SP_RENAME '[TEMP].[Day]', 'GT', 'COLUMN' 我尝试将 Day 重命名为 GT 并收到错误 Incorrect syntax
我说“问题”是因为它没有破坏任何东西,它只是我在 SSMS 中注意到的一件小事。 我运行以下命令: SP_RENAME 'MyTable.OldName', 'NewName' , 'COLUMN'
重命名列名时,列名中包含方括号,我认为这是一个错误, 这是一个示例代码片段, create table [TestTable] (TestColumnName nvarchar(30)) selec
我最近不得不在 SQL Server 2000 中重命名一个表(以及一个列和 FK/PK 约束)而不会丢失数据。似乎没有明显的DDL T-SQL语句来执行这个 Action ,所以我直接用sp_ren
我是一名优秀的程序员,十分优秀!