rocedure [dbo].[p_insertvariabledatareal] as
begin
declare
@id numeric(38, 0),
@tagid nvarchar(36),
@samptime nvarchar(19),
@sampstatus numeric(38, 0),
@ta**alue nvarchar(255),
@couvalue nvarchar(255),
@datacode nvarchar(255),
@rowcount int
--宣告使用者號游標
declare data_cursor cursor for select * from openquery(mysql, 'select * from em_sampledata_collect_real')
open data_cursor --開啟游標
fetch next from data_cursor into @id,@tagid,@samptime,@sampstatus,@ta**alue,@couvalue,@datacode
--獲取游標下一行資料
while(@@fetch_status=0)
begin
select @rowcount=count(1) from es_collect_data_real where id=@id
if (@rowcount=0)
insert into es_collect_data_real(id,collect_item_code,collect_time,collect_value,cou_value) values(@id,@tagid,@samptime,@ta**alue,@couvalue)
else
update es_collect_data_real set collect_value=@ta**alue,cou_value=@couvalue where id=@id
fetch next from data_cursor into @id,@tagid,@samptime,@sampstatus,@ta**alue,@couvalue,@datacode --獲取游標下一行資料 end
close data_cursor --關閉外部游標
deallocate data_cursor --釋放外部游標end
rocedure [dbo].[p_insertvariabledatareal] as
begin
declare
@id numeric(38, 0),
@tagid nvarchar(36),
@samptime nvarchar(19),
@sampstatus numeric(38, 0),
@ta**alue nvarchar(255),
@couvalue nvarchar(255),
@datacode nvarchar(255),
@rowcount int
--宣告使用者號游標
declare data_cursor cursor for select * from openquery(mysql, 'select * from em_sampledata_collect_real')
open data_cursor
--開啟游標
fetch next from data_cursor into @id,@tagid,@samptime,@sampstatus,@ta**alue,@couvalue,@datacode
--獲取游標下一行資料
while(@@fetch_status=0)
begin
select @rowcount=count(1) from es_collect_data_real where id=@id
if (@rowcount=0)
insert into es_collect_data_real(id,collect_item_code,collect_time,collect_value,cou_value) values(@id,@tagid,@samptime,@ta**alue,@couvalue)
else
update es_collect_data_real set collect_value=@ta**alue,cou_value=@couvalue where id=@id
fetch next from data_cursor into @id,@tagid,@samptime,@sampstatus,@ta**alue,@couvalue,@datacode --獲取游標下一行資料
end
close data_cursor --關閉外部游標
deallocate data_cursor --釋放外部游標end
PHP MYSQL查詢一段時間記錄
strone 2011 05 28 00 00 00 strtwo 2011 06 03 24 59 59 strthree 2011 05 28 strfour 2011 06 03 sql select from orders where createtime between strthree....
Mysql查詢一段時間記錄
24小時內記錄 即86400秒 sql select video id,count id as n from rec down where unix timestamp now unix timestamp add time 86400 group by video id order by n de...
Mysql查詢一段時間記錄
24小時內記錄 即86400秒 sql select video id,count id as n from rec down where unix timestamp now unix timestamp add time 86400 group by video id order by n de...