TEXT 13
Sql server sp Guest on 15th December 2024 12:10:14 PM
  1. UPDATE top(1) CallRecords
  2. SET Guid = OtherTable.guid
  3. FROM (SELECT Top(1)
  4.       ct.[RowGuid] as guid
  5.       ,ct.[StartDateTime] as datetime
  6.       ,ct.[Duration] as duration
  7.           --,ex.Extension as agentid
  8.           ,case when ex.Extension like '%T%' then ag.AgentID else ex.Extension end as agentid
  9.           --,ag.AgentID as ag
  10.           --,ex.Description as agentname
  11.           ,out.Number as ani
  12.   FROM [CTSDevices].[dbo].[Calls] as ct
  13.   inner join [CTSDevices].[dbo].callextensions as ex
  14.   on ct.CallExtensionID=ex.ID
  15.   inner join [CTSDevices].[dbo].CallACDAgents ag
  16.   on ct.CallACDAgentID=ag.ID
  17.   inner join [CTSDevices].[dbo].CallOutsidePartyNumbers as out
  18.  on ct.CallOutsidePartyNumberID=out.ID
  19.   --where ex.Extension=callrec.ExtentionID
  20.  -- where out.Number=callrec.CallerId
  21.  where ex.Extension  not like '%#%'
  22.   order by ct.ID desc
  23.  
  24. ) AS OtherTable
  25. WHERE (
  26. CallRecords.ExtentionID = OtherTable.agentid) and CallRecords.CallerId like OtherTable.ani  and CallRecords.Guid is null

Hightechrobo bin is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.