将中文多语更新到英文脚本

by yufeia 2016.3.23 10:06

客户需要将所有中文更新到英文。为安全起见,先使用print打印出所有的脚本,检查无误后,再拷贝出来执行。

-- 将中文多语更新到英文

declare MyCusrort cursor scroll
for
--查找所有的多语表
select name,object_id from sys.tables where name like '%_Trl';

open MyCusrort

declare @name nvarchar(2000)
declare @object_id nvarchar(2000)

fetch next from MyCusrort into @name, @object_id

while ( @@Fetch_Status = 0 )
    begin
		--内部游标开始

		--对于每个多语表进行处理
		declare MyCusrortColumn cursor scroll
			for
		-- 列,通过object_id与sys.tables关联
		select name from sys.columns where object_id=@object_id;
		open MyCusrortColumn

		declare @columnname nvarchar(2000)
		declare @allcolumnname nvarchar(2000)
		declare @combinecolumnname nvarchar(2000)
		set @allcolumnname='';
		fetch next from MyCusrortColumn into @columnname

		while ( @@Fetch_Status = 0 )
			begin
			set @allcolumnname=@allcolumnname+','+@columnname;
		        fetch next from MyCusrortColumn into @columnname
			end

		set @combinecolumnname=
                    replace(right(@allcolumnname,len(@allcolumnname)-1),'SysMLFlag','''en-US'' SysMLFlag')

			-- 拼接insert语句
	    print 'insert into ' + @name+ ' select ' + @combinecolumnname + ' from '+ @name
                                     + ' where sysmlflag=''zh-CN'' and ID not in  
                                     (select ID from '+ @name+'  where sysmlflag in (''zh-CN'',''en-US'')  
                                     group by id having count(ID)>1)'+';'

		close MyCusrortColumn
		deallocate MyCusrortColumn

		--内部游标结束

        fetch next from MyCusrort into @name, @object_id
    end

close MyCusrort
deallocate MyCusrort

 

Tags:

评论 (2) -

USA Proxies 美国 wrote at 2016/7/19 19:14:19 #

I'd like to thank you for the efforts you've put in writing this blog. I am hoping to view the same high-grade blog posts from you later on as well. In fact, your creative writing abilities has encouraged me to get my very own site now ;)

อาหารเสริมลดน้ำหนัก 美国 wrote at 2016/7/20 5:43:50 #

That is a great tip particularly to those fresh to the blogosphere. Short but very accurate information… Many thanks for sharing this one. A must read post!

添加评论



biuquote
微笑得意调皮害羞酷大笑惊讶发呆喜欢可怜尴尬闭嘴噘嘴皱眉伤心抓狂呕吐坏笑漫骂发怒
Loading


RecentComments

评论 RSS

Statistics

989 篇文章
0 个单页
589555 条评论
11 次评分
558573 次访问
访问统计开始于 2019年9月14日
平均日访问 8336 次
当前 139 人在线