从网上下了一个系统,要想把数据库和项目中用到的整合到一起,不过会有重名发生
想把所有表都加上一个前缀,不过一个一个改又麻烦.就写了这个东西
declare curRt cursor
for
select [name] from sysobjects where xtype = 'U' and [name]<> 'dtproperties'
declare @tn nvarchar(20),@sql nvarchar(2000)
open curRt
fetch curRt into @tn
while @@fetch_status =0
begin
select @sql = N'exec sp_rename ''' + @tn + ''', ''thr_' + @tn +''',''OBJECT''' ---这里加的前缀为thr_
execute @sql
fetch next from curRt into @tn
end
close curRt
deallocate curRt
sp_rename和execute功能都很强大很有帮助
希望大家多交流。共同进步