PDC_REPORT_CreazioneDB/sql/Collaudo bfdskrepsei02c/procedure/dbo_sp_updateClienteReportLastAccess.sql
2025-06-26 18:47:11 +02:00

22 lines
594 B
Transact-SQL

CREATE PROCEDURE [dbo].[sp_updateClienteReportLastAccess]
@idReport as int,
@IdCliente as int
AS
BEGIN
SET NOCOUNT ON;
declare @found as int
select @found = count(*) from [dbo].[ReportPerCliente] where IdCliente = @idCliente and IdReport = @idReport
if(@found > 0)
UPDATE [dbo].[ReportPerCliente]
SET DtAssociazione = getdate()
WHERE IdCliente = @idCliente and IdReport = @idReport
else
INSERT INTO [dbo].[ReportPerCliente]
([DtAssociazione]
,[IdReport]
,[IdCliente])
VALUES
(getdate()
,@idReport
,@idCliente)
END