create procedure [dbo].[PostData_Silhouette] as
-- Declare variables for use in the stored procedure
--
-- Variable Description
--------------------------------------------------------------------------------------
-- @PostDate Last post to the ServiceLines table
-- @ServiceSourceID Service Source ID
-- @textADD Text to place in ServiceLines table for an Add event.
-- @textCHANGE Text to place in ServiceLines table for an Change event.
-- @textDELETE Text to place in ServiceLines table for an Delete event.
-- @ImportReservedDIDs Boolean variable (0 = Do not import, -1 Import)
declare @PostDate as datetime
declare @ServiceSourceID as int
declare @textADD as varchar(10) set @textADD='added'
declare @textCHANGE as varchar(10) set @textCHANGE='change'
declare @textDELETE as varchar(10) set @textDELETE='deleted'
declare @ImportReservedDIDs as int set @ImportReservedDIDs=0
declare @tbl_ServiceLines text set @tbl_ServiceLines='ServiceLines'
declare @tbl_ServiceConfig text set @tbl_ServiceConfig='ServiceConfig'
declare @tbl_ServiceSource text set @tbl_ServiceSource='ServiceSource'
declare @tbl_ssTenant text set @tbl_ssTenant='ssTenant'
declare @tbl_ssSite text set @tbl_ssSite='ssSite'
declare @tbl_ssAutoAttendant text set @tbl_ssAutoAttendant='ssAutoAttendant'
declare @tbl_ssCallRouting text set @tbl_ssCallRouting='ssCallRouting'
declare @tbl_ssCallingGroup text set @tbl_ssCallRouting='ssCallingGroup'
--
-- Find a posting date-time and update instance variable @PostDate
--
set @PostDate = (select top 1 RecordDate from @tbl_ssAutoAttendant)
If @PostDate is null set @PostDate = (select top 1 RecordDate from @tbl_ssCallingGroup)
If @PostDate is null set @PostDate = (select top 1 RecordDate from @tbl_ssSubscriber)