日期:2014-05-17 浏览次数:20636 次
declare @tab varchar(100),@col varchar(100),@tsql varchar(6000)
declare ap scroll cursor for
select a.name 'tabname',b.name 'colname'
from sys.tables a
inner join sys.columns b on a.object_id=b.object_id
inner join sys.types c on b.system_type_id=c.system_type_id
where c.name in ('char','varchar','nchar','nvarchar') and b.name<>'成交资金'
open ap
fetch first from ap into @tab,@col
while(@@fetch_status<>-1)
begin
select @tsql='if exists(select 1 from ['+@tab+'] where ['+@col+'] like ''%100万元%'') '
+' exec sp_rename '''+@tab+'.'+@col+''',''金额'',''COLUMN'' '
exec(@tsql)
fetch next from ap into @tab,@col
end
close ap
deallocate ap