本文介绍了插入语句期间链接服务器出现错误的情况的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码: -

使用MYSQL;

声明@Max_Id数字

set @ Max_Id = convert(数字,(从流量中选择max(id));

插入MYSQL.dbo.traffic(id,date,time,ip,resultCode,bytes,url,authuser,sitesID,usersID)

选择id,date,time,ip,resultCode,bytes,url,authuser,sitesID,usersID

来自openquery(MYSQL,'select id,date,time,ip,来自myvar.traffic的resultCode,bytes,url,authuser,sitesID,usersID,其中id>''+ @ Max_Id +'''')





@Max_Id充当字符串,但它是一个变量。我将它声明为变量如何在上面的语句中给出变量

解决方案



code:-
use MYSQL;
Declare @Max_Id numeric
set @Max_Id=convert(numeric,(select max(id) from traffic));
insert into MYSQL.dbo.traffic(id,date,time,ip,resultCode,bytes,url,authuser,sitesID,usersID)
select id,date,time,ip,resultCode,bytes,url,authuser,sitesID,usersID
From openquery(MYSQL,'select id,date,time,ip,resultCode,bytes,url,authuser,sitesID,usersID from myvar.traffic where id > ''+@Max_Id+'''')


@Max_Id is acting as a string but it is a variable.i declare it as variable how can i give the variable in the above statement

解决方案



这篇关于插入语句期间链接服务器出现错误的情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 02:18