相关的OBJECTPROPERTY可参考:
开发过程中,错误免不了。为了纠正错误与规范化。可以使用MS SQL Server的系统存储过程sp_rename与OBJECTPROPERTY来更改重命名。
实例一,更改表名:
复制代码 代码如下:
IF EXISTS(SELECT TOP 1 1 FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[Employee]')
AND OBJECTPROPERTY(id, N'IsUserTable') = 1
)
EXECUTE sp_rename 'Employee', 'Member'
复制代码 代码如下:
EXECUTE sp_rename 'Member.[EmployeeName]', 'Name', 'COLUMN'
复制代码 代码如下:
IF EXISTS(SELECT TOP 1 1 FROM sysobjects WHERE id = OBJECT_ID(N'[PK__Employee__B00879C509746778]')
AND OBJECTPROPERTY(id, N'IsPrimaryKey') = 1)
EXECUTE sp_rename 'PK__Employee__B00879C509746778', 'PK_Member', 'OBJECT'
复制代码 代码如下:
IF EXISTS(SELECT TOP 1 1 FROM sysobjects WHERE id = OBJECT_ID(N'[usp_Employee_Import]')
AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
EXECUTE sp_rename 'usp_Employee_Import', 'MemberInsSp'
新闻热点
疑难解答