我的T-sql,运行在英文2003和英文的sql2005下。
db1,db3,同在这个英文系统中,。但是db1中字段是中文的。
用一个游标把db1.table1的数据一条条导入db3.table3中,导入后就变成???了。
N‘列’,这个方法我也试了。不好使,
set @STR='update dbo.proc_materials
set Name='+char(39)+ISNULL(rtrim(@Name),'NULL')+char(39)+',
description2='+char(39)+ISNULL(rtrim(@description2),'NULL')+char(39)+',
description3='+char(39)+ISNULL(rtrim(@description3),'NULL')+char(39)+',
description5=N'+char(39)+ISNULL(rtrim(@description5),'NULL')+char(39)+',
description6='+char(39)+ISNULL(rtrim(@description6),'NULL')+char(39)+',
description7='+char(39)+'AutoUpdate '+convert(varchar(10),getdate(),120)+char(39)+',
itcontentspecs='+char(39)+ISNULL(rtrim(@itcID),NULL)+char(39)+',
base='+char(39)+ISNULL(rtrim(@baseid),NULL)+char(39)+'
where code= '+char(39)+RTRIM(@Code)+CHAR(39)+' '
PRINT 'SQL='+RTRIM(@STR)
变成这样子了
APORM0001200K FASTRAWL1BLKH/GT/ONJ300-500GM2 ??1??????J300-500GM20K?? FASTRAWL1BLKH/GT/ONJ300-500GM20KAPO ????, ??, 1?, ??, ??????, J?, 300-500?(M), 20??, ?? Frozen at sea, trawl caught, No.1 grade, block, headed, gutted, tail on, J cut,
MATERIALSUMID=7047
??fetchAPO 3 200K 30
?????:2
?????:2
SQL=update dbo.proc_materials
set Name='FASTRAWL1BLKH/GT/ONJ300-500GM2',
description2='??1??????J300-500GM20K??',
description3='FASTRAWL1BLKH/GT/ONJ300-500GM20KAPO',
description5=N'????, ??, 1?, ??, ??????, J?, 300-500?(M), 20??, ??',
description6='Frozen at sea, trawl caught, No.1 grade, block, headed, gutted, tail on, J cut,',
description7='AutoUpdate 2011-01-19',
itcontentspecs='30',
base='3'
where code= 'APORM0001200K'
------解决方案--------------------
你需要将字段类型更改为nvarchar(长度自己定义)
查询,插入,更新前加N
例如:
insert into tb (col) values(N'中文')