From 225aa1499e37faf9d38257caabbadc68d78b427e Mon Sep 17 00:00:00 2001
From: Lucas Faria Mendes <lucas.fariamo08@gmail.com>
Date: Mon, 30 Mar 2026 12:29:41 -0300
Subject: decompiler.com

---
 .../Gestor.Application.Migration.Files.20211223_179.SQL      | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644 Decompiler/Gestor.Application.Migration.Files.20211223_179.SQL

(limited to 'Decompiler/Gestor.Application.Migration.Files.20211223_179.SQL')

diff --git a/Decompiler/Gestor.Application.Migration.Files.20211223_179.SQL b/Decompiler/Gestor.Application.Migration.Files.20211223_179.SQL
new file mode 100644
index 0000000..ea47ee1
--- /dev/null
+++ b/Decompiler/Gestor.Application.Migration.Files.20211223_179.SQL
@@ -0,0 +1,12 @@
+DECLARE @SQL NVARCHAR ( MAX ) = N'INSERT INTO auto (iditem, obs) SELECT i.iditem, r.obs FROM item i INNER JOIN documento d on d.iddocumento = i.iddocumento INNER JOIN controle c on c.idcontrole = d.idcontrole INNER JOIN riscosdiversos r on r.iditem = i.iditem WHERE c.idramo = 37;' 
+DECLARE @sqlDelete NVARCHAR ( MAX ) = N'DELETE FROM riscosdiversos WHERE iditem in (SELECT i.iditem FROM item i INNER JOIN documento d on d.iddocumento = i.iddocumento INNER JOIN controle c on c.idcontrole = d.idcontrole INNER JOIN riscosdiversos r on r.iditem = i.iditem WHERE c.idramo = 37);'
+IF
+	EXISTS (
+SELECT 1 FROM item i INNER JOIN documento d ON d.iddocumento = i.iddocumento
+	INNER JOIN controle c ON c.idcontrole = d.idcontrole
+	INNER JOIN riscosdiversos r ON r.iditem = i.iditem 
+WHERE
+	c.idramo = 37 
+	) BEGIN
+	EXEC sp_executesql @SQL EXEC sp_executesql @sqlDelete 
+END
\ No newline at end of file
-- 
cgit v1.2.3

