{"id":7407,"date":"2017-02-20T09:04:54","date_gmt":"2017-02-20T12:04:54","guid":{"rendered":"http:\/\/www.fabriciolima.net\/?p=7407"},"modified":"2017-02-20T09:04:54","modified_gmt":"2017-02-20T12:04:54","slug":"como-o-sql-prompt-da-red-gate-pode-salvar-seu-emprego","status":"publish","type":"post","link":"https:\/\/fabriciolima.net\/blog\/2017\/02\/20\/como-o-sql-prompt-da-red-gate-pode-salvar-seu-emprego\/","title":{"rendered":"Como o SQL Prompt da Red Gate pode salvar seu emprego"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"irc_mi aligncenter\" src=\"http:\/\/vidadeprogramador.com.br\/wp-content\/uploads\/2011\/03\/tirinha29.png\" alt=\"Image result for update sem where\" width=\"510\" height=\"510\" \/><\/p>\n<p>Fala Pessoal,<\/p>\n<p>J\u00e1 fui um participante de um programa da RedGate chamado <a href=\"https:\/\/www.fabriciolima.net\/blog\/2014\/02\/03\/friends-of-red-gate-2014\/\" target=\"_blank\">Friends of Redgate<\/a> e, desde ent\u00e3o, utilizo a ferramenta SQL Prompt no meu notebook para agilizar o meu trabalho.<\/p>\n<p>Recentemente atualizei o SQL prompt para a vers\u00e3o mais recente e ao executar um DELETE sem WHERE ou um UPDATE sem WHERE ele me mostrou uma mensagem de Warning perguntando se era isso mesmo que eu tinha que fazer.<\/p>\n<p>Eu achei isso genial. Isso pode salvar vidas&#8230; Pode salvar empregos&#8230;. Poderia ter salvo o Ga\u00facho da foto acima&#8230; rsrs<\/p>\n<p>Quem nunca ouviu uma hist\u00f3ria de algu\u00e9m que esqueceu de selecionar a cl\u00e1usula WHERE e fez um DELETE ou UPDATE da tabela inteira???<\/p>\n<p>J\u00e1 perdi as contas de quantos restores tive que fazer para salvar algu\u00e9m que fez essa opera\u00e7\u00e3o equivocada.<\/p>\n<p>Vamos fazer um teste?<\/p>\n<p>Criei uma tabela chamada Tabela_Ultra_Mega_Importante e populei com algumas linhas:<\/p>\n<pre class=\"lang:tsql decode:true\">CREATE TABLE Tabela_Ultra_Mega_Importante(\r\nId_Tabela INT IDENTITY,\r\nDt_Cadastro DATETIME DEFAULT(GETDATE()),\r\nDs_Descricao VARCHAR(1000))\r\nGO\r\nINSERT INTO Tabela_Ultra_Mega_Importante(Ds_Descricao)\r\nSELECT 'Vou fazer merda'\r\nGO 10000<\/pre>\n<p>Em seguida tentei dar um DELETE sem WHERE:<\/p>\n<pre class=\"lang:tsql decode:true \">DELETE FROM Tabela_Ultra_Mega_Importante<\/pre>\n<p>Ao rodar esse DELETE recebi a mensagem abaixo:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-7409 aligncenter\" src=\"https:\/\/www.fabriciolima.net\/blog\/wp-content\/uploads\/2017\/02\/DELETEsemWHERE.png\" alt=\"\" width=\"511\" height=\"205\" srcset=\"https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2017\/02\/DELETEsemWHERE.png 593w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2017\/02\/DELETEsemWHERE-300x120.png 300w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2017\/02\/DELETEsemWHERE-410x165.png 410w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2017\/02\/DELETEsemWHERE-100x40.png 100w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2017\/02\/DELETEsemWHERE-275x110.png 275w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2017\/02\/DELETEsemWHERE-20x8.png 20w\" sizes=\"auto, (max-width: 511px) 100vw, 511px\" \/><\/p>\n<p>Em seguida tentei dar um UPDATE sem WHERE:<\/p>\n<pre class=\"lang:tsql decode:true\">UPDATE dbo.Tabela_Ultra_Mega_Importante\r\nSET Ds_Descricao = 'Fazendo merda novamente'<\/pre>\n<p>Ao rodar esse UPDATE recebi a mensagem abaixo:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-7408 aligncenter\" src=\"https:\/\/www.fabriciolima.net\/blog\/wp-content\/uploads\/2017\/02\/UPDATEsemWHERE.png\" alt=\"\" width=\"510\" height=\"203\" srcset=\"https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2017\/02\/UPDATEsemWHERE.png 603w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2017\/02\/UPDATEsemWHERE-300x119.png 300w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2017\/02\/UPDATEsemWHERE-600x240.png 600w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2017\/02\/UPDATEsemWHERE-410x163.png 410w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2017\/02\/UPDATEsemWHERE-100x40.png 100w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2017\/02\/UPDATEsemWHERE-275x109.png 275w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2017\/02\/UPDATEsemWHERE-20x8.png 20w\" sizes=\"auto, (max-width: 510px) 100vw, 510px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Achei isso muito legal. Ainda n\u00e3o tinha visto essa funcionalidade.<\/p>\n<p>Mais uma vez, isso pode salvar vidas&#8230;. Isso pode salvar seu emprego&#8230; rsrs<\/p>\n<p>Pelo que l\u00ed, essa mensagem est\u00e1 dispon\u00edvel a partir da vers\u00e3o 7.2 do SQL Prompt. Segue o link para baixar e testar a ferramenta: <a href=\"http:\/\/www.red-gate.com\/products\/sql-development\/sql-prompt\/\" target=\"_blank\">Trial SQL Prompt<\/a><\/p>\n<p>Recentemente a empresa do meu amigo Erickson passou a representar a RedGate aqui no Brasil. Ent\u00e3o, se tiver interesse em comprar algum produto deles, procure a <a href=\"http:\/\/www.sqlcore.com.br\/2017\/02\/10\/lancamento-da-parceria-entre-redgate-e-sqlcore\/\" target=\"_blank\">SQLCORE<\/a>.<\/p>\n<p><b>Gostou dessa Dica?<\/b><\/p>\n<p>Curta, comente, compartilhe\u2026<\/p>\n<p>Assine meu canal no <a class=\"external-link wpel-icon-left\" href=\"https:\/\/www.youtube.com\/channel\/UCeBRAO_LLrUdSrOXIywjzRA\" target=\"_blank\" rel=\"external noopener noreferrer nofollow\" data-wpel-link=\"external\">Youtube<\/a> e curta minha p\u00e1gina no <a class=\"external-link wpel-icon-left\" href=\"https:\/\/www.facebook.com\/FabricioLimaSolucoesemBancodeDados\/\" target=\"_blank\" rel=\"external noopener noreferrer nofollow\" data-wpel-link=\"external\">Facebook<\/a> para receber Dicas de Leituras, V\u00eddeos e Eventos sobre SQL Server.<\/p>\n<p>At\u00e9 a pr\u00f3xima.<\/p>\n<p>Fabr\u00edcio Lima<\/p>\n<p>MCITP \u2013 Database Administrator<\/p>\n<p>Consultor e Instrutor SQL Server<\/p>\n<p>Trabalha com SQL Server desde 2006<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Fala Pessoal, J\u00e1 fui um participante de um programa da RedGate chamado Friends of Redgate e, desde ent\u00e3o, utilizo a ferramenta SQL Prompt no meu notebook para agilizar o meu trabalho. Recentemente atualizei o SQL prompt para a vers\u00e3o mais recente e ao executar um DELETE sem WHERE ou um UPDATE sem WHERE ele me [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[3,33,280],"tags":[1461,1466,1465,1460,749,746,754,1462],"class_list":["post-7407","post","type-post","status-publish","format-standard","hentry","category-administracao-de-bd","category-sql-server","category-virtual-pass-br","tag-delete-sem-where","tag-ferramenta-desenvolvedor-sql","tag-ferramenta-sql-server","tag-forg","tag-friends-of-redgate","tag-redgate","tag-sql-prompt","tag-update-sem-where"],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/posts\/7407","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/comments?post=7407"}],"version-history":[{"count":0,"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/posts\/7407\/revisions"}],"wp:attachment":[{"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/media?parent=7407"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/categories?post=7407"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/tags?post=7407"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}