declare @checklistName as varchar(100), @retailStoreId as varchar(100)
declare @taskStart as datetime
declare @taskFinish as datetime
declare @checkListId as int, @locationListId as int
declare @crontabExpression as varchar(256)
set @checklistName = 'CheckList Abertura de Loja' --- Nome que terá a tarefa
set @checkListId = 1 --- Identificador do CheckList criado
set @taskStart = '2017-05-02 00:00:00' --- Data de inicio
set @taskFinish = '2017-06-02 00:00:00' --- Data de final
set @crontabExpression = '0 9 * * *' /* exemplo para disparar as 9hs */
set @retailStoreId = 'S0057' --- Loja para ser criada a tarefa
/* Criação da Lista de Lojas */
if (select COUNT(*) from tm.LocationItem li where li.RetailStoreId = @retailStoreId) > 0
begin
select top 1 @locationListId = LocationListId from tm.LocationItem li where li.RetailStoreId = @retailStoreId
end
else
begin
declare @identity as int
insert into tm.LocationList values ('-', 0)
set @identity = @@IDENTITY
insert into tm.LocationItem values (@identity, null, @retailStoreId, 'ADD', null)
end
/* Criação do agendamento do CheckList */
insert into tm.SchedConfig values
(6, @checklistName, @checklistName, 'A', @crontabExpression,
@taskStart, @taskFinish, 'Support_Tlantic', GETDATE(), 'Support_Tlantic', GETDATE(),
@checkListId, @locationListId, null, 82, null, 2, 'S', null, null, 1, 0)