From 674ca83ba9243a9e95a7568c797668dab6aee26a Mon Sep 17 00:00:00 2001
From: Lucas Faria Mendes <lucas.fariamo08@gmail.com>
Date: Mon, 30 Mar 2026 10:35:25 -0300
Subject: feat: upload files

---
 Gestor.Application.Migration.Files.20210825_174.SQL | 9 +++++++++
 1 file changed, 9 insertions(+)
 create mode 100644 Gestor.Application.Migration.Files.20210825_174.SQL

(limited to 'Gestor.Application.Migration.Files.20210825_174.SQL')

diff --git a/Gestor.Application.Migration.Files.20210825_174.SQL b/Gestor.Application.Migration.Files.20210825_174.SQL
new file mode 100644
index 0000000..3776d35
--- /dev/null
+++ b/Gestor.Application.Migration.Files.20210825_174.SQL
@@ -0,0 +1,9 @@
+DECLARE @sql NVARCHAR(MAX) = N'INSERT INTO vida (iditem, plano, obs) SELECT i.iditem, i.descricao, 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 = 47;'
+
+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 = 47);'
+
+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 = 47)
+BEGIN
+    exec sp_executesql @sql
+    exec sp_executesql @sqlDelete
+END
\ No newline at end of file
-- 
cgit v1.2.3

