有一套韩文的数据库,想导入到中文系统下,并让它能正常保存中文。
现在导到中文系统后数据库的语言仍是韩文,保存中文是乱码。
不想把字段都改成nvarchar的,那样改动量太大了。有没有直接修改数据库语言的方法,或者在导入的时候有什么方法?
sqlserver不是很熟,麻烦写详细点,谢谢
现在导到中文系统后数据库的语言仍是韩文,保存中文是乱码。
不想把字段都改成nvarchar的,那样改动量太大了。有没有直接修改数据库语言的方法,或者在导入的时候有什么方法?
sqlserver不是很熟,麻烦写详细点,谢谢
use master
go
ALTER DATABASE 数据库名 COLLATE 排序规则名
declare tb cursor for
SELECT sql='alter table ['+d.name
+'] alter column ['+a.name+'] n'
+b.name+'('+cast(a.length*2 as varchar)+')'
FROM syscolumns a left join systypes b
on a.xtype=b.xusertype inner join sysobjects d
on a.id=d.id and d.xtype='U' and d.name<>'dtproperties'
where
b.name in('char','varchar')
and
not exists(SELECT 1 FROM sysobjects where xtype='PK' and name in (
SELECT name FROM sysindexes WHERE indid in(
SELECT indid FROM sysindexkeys WHERE id = a.id AND colid=a.colid
))) --主键不能修改
order by d.name,a.name
declare @sql varchar(1000)
open tb
fetch next from tb into @sql
while @@fetch_status = 0
begin
exec(@sql)
fetch next from tb into @sql
end
close tb
deallocate tb
go