sqlserver触发器往mysql插入数据错误问题
我在sqlserver查询分析器中输入语句 能够成功执行
insert into OPENROWSET( 'MSDASQL', 'DRIVER={MySQL ODBC 5.1 Driver}; SERVER=localhost; PORT=3306;DATABASE=wpf; USER=root;PASSWORD=w001; STMT=set names gb2312; OPTION=2049','select * from tAbc;' ) select 0,'admin','admin','0','test1','2013-08-05 15:00:26','1','0','0','','','','0','0'
alter trigger mysqlTest_1 on [t_1mysql]
for insert,update
as
declare @var1 varchar(max),@var2 varchar(max),@txt nvarchar(max)
select @var1=F1 from inserted
set @txt=
'insert into OPENROWSET(
''MSDASQL'',
''DRIVER={MySQL ODBC 5.1 Driver};
SERVER=localhost;
PORT=3306;DATABASE=wpf;
USER=root;PASSWORD=w001;
STMT=set names gb2312;
OPTION=2049'',''select * from tAbc;''
)
select 0,''admin'',''admin'',''0'','''+isnull(@var1,'')+''',''2013-08-05 15:00:26'',''1'',''0'',''0'','''','''','''',''0'',''0'''
exec sp_executesql @txt
insert into t_1mysql
values('test1','abc')