select replace(name,'aa','bb') from sysobjects where type='U' and name like '%_aa_%'
sp_rename 更改当前数据库中用户创建对象(如表、列或用户定义数据类型)的名称。具体见帮助
--是是下面的存储过程 Create Procedure P_RepalceName As Declare @Name VarChar(100),@RepalceName VarChar(100) Declare Other_Cursor Cursor For Select Name,Replace(Name,'aa','bb') From sysobjects Where type='U' And Name Like '%_aa_%' Open Other_Cursor Fetch Next From Other_Cursor Into @Name,@RepalceName While @@FETCH_STATUS = 0 Begin EXEC sp_rename @Name,@RepalceName Fetch Next From Other_Cursor Into @Name,@RepalceName End Close Other_Cursor Deallocate Other_CursorgoExec P_RepalceName go Drop Procedure P_RepalceName
from sysobjects
where type='U' and name like '%_aa_%'
更改当前数据库中用户创建对象(如表、列或用户定义数据类型)的名称。具体见帮助
Create Procedure P_RepalceName As
Declare @Name VarChar(100),@RepalceName VarChar(100)
Declare Other_Cursor Cursor For
Select Name,Replace(Name,'aa','bb') From sysobjects Where type='U' And Name Like '%_aa_%'
Open Other_Cursor
Fetch Next From Other_Cursor Into @Name,@RepalceName
While @@FETCH_STATUS = 0
Begin
EXEC sp_rename @Name,@RepalceName
Fetch Next From Other_Cursor Into @Name,@RepalceName
End
Close Other_Cursor
Deallocate Other_CursorgoExec P_RepalceName
go
Drop Procedure P_RepalceName