USE [SZ_OpMon]
GO
/****** Object: StoredProcedure [dbo].[Test] Script Date: 2014/8/5 10:41:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER Procedure [dbo].[Test]
@st NVarchar(19),
@et Nvarchar(19)
as
Set NoCount ON
Begin try
Declare @sql as varchar(8000)
Declare @vname as varchar(80)
Declare @tagList as Varchar(8000)
Declare @qt as nvarchar(1)
set @qt=char(39)
Declare cvname cursor local for
(select distinct VariableName
from AATISvw_EventVariables a
inner join
runtime.dbo.tag b
on b.tagName = a.VariableName
inner join
AATIS_ProductionMachines c
on c.MachineKey=a.MachineKey
and c.MachineType = 'IntegerLotInProgress')
open cvname
fetch next from cvname into @vname
while @@FETCH_STATUS=0
begin
set @tagList= @taglist+@qt+@vname +@qt+ ','
begin
set @sql=' insert into insert into aatis_tmpAnalogHist exec master..xp_AnalogHistoryDelta'
+@qt+@st+@qt+','+@qt+@et+@qt+','
+'1000'+@taglist
---print @sql
execute (@sql)
set @tagList=''
end
fetch next from cvname into @vname
end
close cvname
deallocate cvname
end try
begin catch
end catch