tag:blogger.com,1999:blog-20519688480066598832024-03-13T18:43:29.698-03:00Code AuthorityCódigos, códigos e mais códigos ... sem falar é claro de muito conhecimento em tudo que for TI...Everton Limahttp://www.blogger.com/profile/06038304424400850290noreply@blogger.comBlogger14125tag:blogger.com,1999:blog-2051968848006659883.post-63395205615935128552012-12-05T14:27:00.003-02:002012-12-11T14:08:29.324-02:00SQL Dinâmico em Stored Procedure (Building Dynamic SQL In a Stored Procedure) (Parte 1/3)<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<h3 style="text-align: left;">
<span class="" id="result_box" lang="pt"><span class="hps">Introdução</span></span></h3>
<br />
<span class="" id="result_box" lang="pt"><span class="hps">O SQL Dinâmico em STORED PROCEDURE</span> <span class="hps">é uma declaração</span> <span class="hps atn">Transact-</span><span class="">SQL</span> <span class="hps">simples ou</span> <span class="hps">um conjunto de instruções</span> <span class="hps">armazenadas</span> <span class="hps">em uma variável e</span> <span class="hps">executado através de</span> <span class="hps">um comando</span> <span class="hps">SQL.</span> <span class="hps">Pode haver</span> <span class="hps">vários métodos</span> <span class="hps">de aplicação </span><span class="hps">no SQL Server.</span> <span class="hps">Este artigo</span> <span class="hps">irá mostrar-lhe</span> <span class="hps">um bom método</span> <span class="hps">de aplica isso.</span> <span class="hps">Antes de entrar em</span> <span class="hps">uma explicação detalhada,</span> <span class="hps">deixe-me perguntar</span> <span class="hps">"Quando usar</span> <span class="hps">SQL</span> <span class="hps">dinâmico?</span><span class="">"</span> <span class="hps">Nós não podemos</span> <span class="hps">dizer definitivamente que</span> o<span class="hps"> SQL</span> <span class="hps">estático (comando direto) irá</span> <span class="hps">atender</span> <span class="hps">todas as nossas necessidades</span> <span class="hps">de programação.</span> O <span class="hps">Dynamic SQL</span> <span class="hps">é necessário quando</span> <span class="hps">precisamos</span> <span class="hps">recuperar um conjunto de</span> <span class="hps">registros com base em</span> <span class="hps">parâmetros de pesquisa.</span> <span class="hps">Digamos, por exemplo</span> <span class="hps">- Uma</span> <span class="hps">tela de pesquisa</span> <span class="hps">empregado</span> <span class="hps">ou um relatório de</span> <span class="hps">propósito geral</span> <span class="hps">que precisa</span> <span class="hps">executar uma instrução e</span> <span class="hps">selecionar com base em</span> <span class="hps">uma cláusula WHERE</span> <span class="hps">diferente.</span><br class="" /><br class="" /><span class="hps">NOTA:</span> <span class="hps">Mais importante ainda,</span> <span class="hps">as consultas</span> <span class="hps">SQL dinâmicas</span> <span class="hps">em uma variável</span> <span class="hps">não são compilados,</span> <span class="hps">analisados,</span> <span class="hps">marcada por erros</span> <span class="hps">até que eles sejam</span> <span class="hps">executados.</span></span><br />
<span class="" lang="pt"><br class="" /></span>
<br />
<h3 style="text-align: left;">
<span class="" lang="pt"><span class="hps">sp_executesql</span> <span class="hps">Vs</span> comando EXECUTE</span></h3>
<span class="" lang="pt"><br class="" />Na construção <span class="hps"> dinâmica</span> de <span class="hps">Transact</span><span class="">-SQL</span> <span class="hps">pode ser</span> <span class="hps">executado através do comando EXECUTE</span> <span class="hps">ou declaração</span> <span class="hps">sp_executesql.</span> <span class="hps">Aqui</span><span class="">, neste artigo e</span> <span class="hps">nos meus exemplos,</span> <span class="hps">eu vou usar</span> <span class="hps">sp_executesql</span> <span class="hps">que é mais eficiente</span><span class="">, mais rápido</span> <span class="hps">na execução e</span> <span class="hps">também</span> <span class="hps">apóia a substituição de</span> <span class="hps">parâmetro.</span> <span class="hps">Se estamos usando</span> <span class="hps">EXECUTE</span> <span class="hps">para executar</span> <span class="hps">a seqüência de</span> <span class="hps">SQL</span><span class="">, </span><span class="hps">todos os parâmetros</span> <span class="hps">devem ser convertidos em</span> texto<span class="hps"> e</span> concatenado n<span class="hps">a consulta</span> <span class="hps">antes da execução.</span> O <span class="hps">sp_executesql</span> <span class="hps">proporciona uma melhor</span> <span class="hps">maneira de implementar isso</span><span class="">.</span> <span class="hps">Isso nos permite</span> <span class="hps">substituir</span> <span class="hps">os valores dos parâmetros</span> <span class="hps">para qualquer</span> <span class="hps">parâmetro especificado</span> <span class="hps">na string</span> <span class="hps">SQL.</span> <span class="hps">Antes de entrar no</span> <span class="hps">exemplo real</span><span class="">, deixe-me</span> <span class="hps">diferenciar</span> <span class="hps">esses dois comandos</span> <span class="hps">com um exemplo simples</span><span class="">.</span> Consulta:<span class="hps"> selecionar um</span> <span class="hps">registro da tabela</span> <span class="hps">empregado</span> <span class="hps">utilizando o ID</span> <span class="hps">na cláusula</span> <span class="hps">WHERE.</span></span><br />
<div>
<span class="" lang="pt"><span class="hps"><br /></span></span></div>
<div>
<span class="" lang="pt"><span class="hps" style="font-family: inherit;"></span></span><br />
<div style="background-color: white; color: #111111;">
<span class="" lang="pt"><span class="hps" style="font-family: inherit;">A sintaxe básica do comando <code style="border: 0px; color: #990000; margin: 0px; padding: 0px;">EXECUTE:</code></span></span></div>
<span class="" lang="pt"><span class="hps" style="font-family: inherit;">
</span></span>
<br />
<div class="pre-action-link" id="premain0" style="background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-width: 0px 0px 1px; color: #005782; margin: 0px; padding: 0px; text-align: right;" width="100%">
<span class="" lang="pt"><span class="hps" style="font-family: inherit;"><br /></span></span></div>
<span class="" lang="pt"><span class="hps" style="font-family: inherit;">
</span></span>
<br />
<pre id="pre0" lang="sql" style="background-color: #fbedbb; border: 1px solid rgb(251, 237, 187); overflow: auto; padding: 6px; white-space: pre-wrap; word-wrap: break-word;"><span class="" lang="pt"><span class="hps" style="font-family: inherit;"><span class="code-keyword" style="border: 0px; color: blue; margin: 0px; padding: 0px;">EXECUTE</span>(@SQLStatement)</span></span></pre>
<span class="" lang="pt"><span class="hps" style="font-family: inherit;">
</span></span>
<br />
<div style="background-color: white; color: #111111;">
<span class="" lang="pt"><span class="hps" style="font-family: inherit;"><br /></span></span></div>
<span class="" lang="pt"><span class="hps" style="font-family: inherit;">
</span></span>
<br />
<div style="background-color: white; color: #111111;">
<span class="" lang="pt"><span class="hps" style="font-family: inherit;">A sintaxe básica para usar o <code style="border: 0px; color: #990000; margin: 0px; padding: 0px;">sp_executesql</code>:</span></span></div>
<span class="" lang="pt"><span class="hps" style="font-family: inherit;">
</span></span>
<br />
<div class="pre-action-link" id="premain1" style="background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-width: 0px 0px 1px; color: #005782; margin: 0px; padding: 0px; text-align: right;" width="100%">
<span class="" lang="pt"><span class="hps" style="font-family: inherit;"><br /></span></span></div>
<span class="" lang="pt"><span class="hps" style="font-family: inherit;">
</span></span>
<pre id="pre1" lang="sql" style="background-color: #fbedbb; border: 1px solid rgb(251, 237, 187); overflow: auto; padding: 6px; white-space: pre-wrap; word-wrap: break-word;"><span class="" lang="pt"><span class="hps" style="font-family: inherit;">sp_executesql [@SQLStatement],[@ParameterDefinitionList],
[@ParameterValueList]</span></span></pre>
<span class="" lang="pt"><span class="hps" style="font-family: inherit;">
<h3 style="background-color: white; font-weight: normal;">
<span style="font-family: inherit; font-size: small;">Exemplo 1.0</span></h3>
<div>
<pre id="pre2" lang="sql" style="background-color: #fbedbb; border: 1px solid rgb(251, 237, 187); font-size: 9pt; overflow: auto; padding: 6px; white-space: pre-wrap; word-wrap: break-word;"><span class="code-comment" style="border: 0px; color: green; font-family: Consolas, 'Courier New', Courier, mono; font-style: italic; margin: 0px; padding: 0px;">/*</span><span class="code-comment" style="border: 0px; color: green; font-family: Consolas, 'Courier New', Courier, mono; font-style: italic; margin: 0px; padding: 0px;"> Declaração de Variávies */</span><span style="font-family: Consolas, Courier New, Courier, mono;">
</span><span style="font-family: inherit;"><span class="code-keyword" style="border: 0px; color: blue; margin: 0px; padding: 0px;">DECLARE</span> @EmpID <span class="code-keyword" style="border: 0px; color: blue; margin: 0px; padding: 0px;">AS</span> <span class="code-keyword" style="border: 0px; color: blue; margin: 0px; padding: 0px;">SMALLINT</span>
<span class="code-keyword" style="border: 0px; color: blue; margin: 0px; padding: 0px;">DECLARE</span> @SQLQuery <span class="code-keyword" style="border: 0px; color: blue; margin: 0px; padding: 0px;">AS</span> <span class="code-keyword" style="border: 0px; color: blue; margin: 0px; padding: 0px;">NVARCHAR</span>(<span class="code-digit" style="border: 0px; color: navy; margin: 0px; padding: 0px;">500</span>)
<span class="code-comment" style="border: 0px; color: green; font-style: italic; margin: 0px; padding: 0px;">/*</span><span class="code-comment" style="border: 0px; color: green; font-style: italic; margin: 0px; padding: 0px;"> Setando valor dos parâmetros */</span>
<span class="code-keyword" style="border: 0px; color: blue; margin: 0px; padding: 0px;">SET</span> @EmpID = <span class="code-digit" style="border: 0px; color: navy; margin: 0px; padding: 0px;">1001</span>
<span class="code-comment" style="border: 0px; color: green; font-style: italic; margin: 0px; padding: 0px;">/*</span><span class="code-comment" style="border: 0px; color: green; font-style: italic; margin: 0px; padding: 0px;"> Construindo o SQL com o parâmetro */</span>
<span class="code-keyword" style="border: 0px; color: blue; margin: 0px; padding: 0px;">SET</span> @SQLQuery = <span class="code-string" style="border: 0px; color: purple; margin: 0px; padding: 0px;">'</span><span class="code-string" style="border: 0px; color: purple; margin: 0px; padding: 0px;">SELECT * FROM tblEmployees WHERE EmployeeID = '</span> +
CAST(@EmpID <span class="code-keyword" style="border: 0px; color: blue; margin: 0px; padding: 0px;">AS</span> <span class="code-keyword" style="border: 0px; color: blue; margin: 0px; padding: 0px;">NVARCHAR</span>(<span class="code-digit" style="border: 0px; color: navy; margin: 0px; padding: 0px;">10</span>))
<span class="code-comment" style="border: 0px; color: green; font-style: italic; margin: 0px; padding: 0px;">/*</span><span class="code-comment" style="border: 0px; color: green; font-style: italic; margin: 0px; padding: 0px;"> Executando a Transact-SQL */</span>
<span class="code-keyword" style="border: 0px; color: blue; margin: 0px; padding: 0px;">EXECUTE</span>(@SQLQuery)</span></pre>
<div style="background-color: white; color: #111111; font-size: 13.63636302947998px;">
<span style="font-family: inherit;">No exemplo 1.0 acima, temos 2 variáveis declaras. A proimeira variável <code style="border: 0px; color: #990000; font-size: 11pt; margin: 0px; padding: 0px;">@EmpID</code> é usada como parâmetro da procura e a segunda variável <code style="border: 0px; color: #990000; font-size: 11pt; margin: 0px; padding: 0px;">@SQLQuery</code> é usada para construir a string SQL, a consulta propriamente dita. Pode-se perceber que essa variável <code style="border: 0px; color: #990000; font-size: 11pt; margin: 0px; padding: 0px;">@EmpID</code> é convertida para <code style="border: 0px; color: #990000; font-size: 11pt; margin: 0px; padding: 0px;">NVarchar </code>para fazer parte da string T-SQL. Se você imprimir a variável <code style="border: 0px; color: #990000; font-size: 11pt; margin: 0px; padding: 0px;">@SQLQuery</code> (<code style="border: 0px; color: #990000; font-size: 11pt; margin: 0px; padding: 0px;">PRINT @SQLQuery</code>), você terá uma visualização aprecida com esta:</span></div>
<div class="pre-action-link" id="premain3" style="background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-width: 0px 0px 1px; color: #005782; font-size: 11px; margin: 0px; padding: 0px; text-align: right;" width="100%">
<span style="font-family: inherit;"><br /></span></div>
<pre id="pre3" lang="sql" style="background-color: #fbedbb; border: 1px solid rgb(251, 237, 187); font-size: 9pt; overflow: auto; padding: 6px; white-space: pre-wrap; word-wrap: break-word;"><span style="font-family: inherit;"><span class="code-keyword" style="border: 0px; color: blue; margin: 0px; padding: 0px;">SELECT</span> * <span class="code-keyword" style="border: 0px; color: blue; margin: 0px; padding: 0px;">FROM</span> tblEmployees <span class="code-keyword" style="border: 0px; color: blue; margin: 0px; padding: 0px;">WHERE</span> EmployeeID = <span class="code-digit" style="border: 0px; color: navy; margin: 0px; padding: 0px;">1001</span></span></pre>
<div style="background-color: white; color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 13.63636302947998px;">
<br /></div>
<div style="background-color: white;">
<div style="color: #111111; font-size: 13.63636302947998px;">
<span style="font-family: inherit;">No final a query acima será executada pelo comando <code style="border: 0px; color: #990000; font-size: 11pt; margin: 0px; padding: 0px;">EXECUTE</code></span></div>
<div style="color: #111111; font-family: 'Segoe UI', Arial, sans-serif; font-size: 13.63636302947998px;">
<code style="border: 0px; color: #990000; font-family: Consolas, 'Courier New', Courier, mono; font-size: 11pt; margin: 0px; padding: 0px;"><br /></code></div>
<div style="color: #111111; font-size: 13.63636302947998px;">
<code style="border: 0px; color: #990000; font-size: 11pt; margin: 0px; padding: 0px;"></code></div>
<h4 style="color: #111111; font-size: 13.63636302947998px; text-align: left;">
</h4>
<h3 style="color: black; font-family: 'Times New Roman'; font-size: 13.63636302947998px; font-weight: normal;">
<code style="border: 0px; color: #990000; font-size: 11pt; margin: 0px; padding: 0px;"><span style="font-family: inherit; font-size: small;">Exemplo 1.1</span></code></h3>
<div class="pre-action-link" id="premain4" style="border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-width: 0px 0px 1px; color: #005782; font-family: 'Segoe UI', Arial, sans-serif; font-size: 11px; margin: 0px; padding: 0px; text-align: right;" width="100%">
<code style="border: 0px; color: #990000; font-size: 11pt; margin: 0px; padding: 0px;"><br /></code></div>
<pre id="pre4" lang="sql" style="background-color: #fbedbb; border: 1px solid rgb(251, 237, 187); color: black; font-family: Consolas, 'Courier New', Courier, mono; overflow: auto; padding: 6px; white-space: pre-wrap; word-wrap: break-word;"><code style="border: 0px; color: #990000; margin: 0px; padding: 0px;"><span class="code-keyword" style="border: 0px; color: blue; margin: 0px; padding: 0px;">DECLARE</span> @EmpID <span class="code-keyword" style="border: 0px; color: blue; margin: 0px; padding: 0px;">AS</span> <span class="code-keyword" style="border: 0px; color: blue; margin: 0px; padding: 0px;">SMALLINT</span>
<span class="code-keyword" style="border: 0px; color: blue; margin: 0px; padding: 0px;">DECLARE</span> @SQLQuery <span class="code-keyword" style="border: 0px; color: blue; margin: 0px; padding: 0px;">AS</span> <span class="code-keyword" style="border: 0px; color: blue; margin: 0px; padding: 0px;">NVARCHAR</span>(<span class="code-digit" style="border: 0px; color: navy; margin: 0px; padding: 0px;">500</span>)
<span class="code-keyword" style="border: 0px; color: blue; margin: 0px; padding: 0px;">DECLARE</span> @ParameterDefinition <span class="code-keyword" style="border: 0px; color: blue; margin: 0px; padding: 0px;">AS</span> <span class="code-keyword" style="border: 0px; color: blue; margin: 0px; padding: 0px;">NVARCHAR</span>(<span class="code-digit" style="border: 0px; color: navy; margin: 0px; padding: 0px;">100</span>)
<span class="code-comment" style="border: 0px; color: green; font-style: italic; margin: 0px; padding: 0px;">/*</span><span class="code-comment" style="border: 0px; color: green; font-style: italic; margin: 0px; padding: 0px;"> Setando valores do parâmetro */</span>
<span class="code-keyword" style="border: 0px; color: blue; margin: 0px; padding: 0px;">SET</span> @EmpID = <span class="code-digit" style="border: 0px; color: navy; margin: 0px; padding: 0px;">1001</span>
<span class="code-comment" style="border: 0px; color: green; font-style: italic; margin: 0px; padding: 0px;">/*</span><span class="code-comment" style="border: 0px; color: green; font-style: italic; margin: 0px; padding: 0px;"> Contruindo o SQL incluindo os parâmetros */</span>
<span class="code-keyword" style="border: 0px; color: blue; margin: 0px; padding: 0px;">SET</span> @SQLQuery = <span class="code-string" style="border: 0px; color: purple; margin: 0px; padding: 0px;">'</span><span class="code-string" style="border: 0px; color: purple; margin: 0px; padding: 0px;">SELECT * FROM tblEmployees WHERE EmployeeID = @EmpID'</span>
<span class="code-comment" style="border: 0px; color: green; font-style: italic; margin: 0px; padding: 0px;">/*</span><span class="code-comment" style="border: 0px; color: green; font-style: italic; margin: 0px; padding: 0px;"> Especificando o formato do parâmetro */</span>
<span class="code-keyword" style="border: 0px; color: blue; margin: 0px; padding: 0px;">SET</span> @ParameterDefinition = <span class="code-string" style="border: 0px; color: purple; margin: 0px; padding: 0px;">'</span><span class="code-string" style="border: 0px; color: purple; margin: 0px; padding: 0px;">@EmpID SMALLINT'</span>
<span class="code-comment" style="border: 0px; color: green; font-style: italic; margin: 0px; padding: 0px;">/*</span><span class="code-comment" style="border: 0px; color: green; font-style: italic; margin: 0px; padding: 0px;"> Executando o SQL */</span>
<span class="code-keyword" style="border: 0px; color: blue; margin: 0px; padding: 0px;">EXECUTE</span> sp_executesql @SQLQuery, @ParameterDefinition, @EmpID</code></pre>
<div style="font-size: 13.63636302947998px; text-align: left;">
<code style="border: 0px; font-size: 11pt; margin: 0px; padding: 0px;"><span style="font-family: inherit;">In the example 1.1, there are two variables declared. The variable <code style="border: 0px; font-size: 11pt; margin: 0px; padding: 0px;">@EmpID</code> is used as a parameter to the SQL Query and second variable <code style="border: 0px; font-size: 11pt; margin: 0px; padding: 0px;">@SQLQuery</code> is used to build the SQL String, the third variable <code style="border: 0px; font-size: 11pt; margin: 0px; padding: 0px;">@ParameterDefinition</code> is used to specify the parameter format before executing the SQL string. If you print the <code style="border: 0px; font-size: 11pt; margin: 0px; padding: 0px;">@SQLQuery</code> string (<code style="border: 0px; font-size: 11pt; margin: 0px; padding: 0px;">PRINT @SQLQuery</code>), you will get the query as shown below:</span></code></div>
<div class="pre-action-link" id="premain5" style="border-bottom-color: rgb(204, 204, 204); border-bottom-style: solid; border-width: 0px 0px 1px; color: #005782; font-family: 'Segoe UI', Arial, sans-serif; font-size: 11px; margin: 0px; padding: 0px; text-align: right;" width="100%">
<code style="border: 0px; color: #990000; font-size: 11pt; margin: 0px; padding: 0px;"><br /></code></div>
<pre id="pre5" lang="sql" style="background-color: #fbedbb; border: 1px solid rgb(251, 237, 187); color: black; font-family: Consolas, 'Courier New', Courier, mono; font-size: 9pt; overflow: auto; padding: 6px; white-space: pre-wrap; word-wrap: break-word;"><code style="border: 0px; color: #990000; font-size: 11pt; margin: 0px; padding: 0px;"><span class="code-keyword" style="border: 0px; color: blue; margin: 0px; padding: 0px;">SELECT</span> * <span class="code-keyword" style="border: 0px; color: blue; margin: 0px; padding: 0px;">FROM</span> tblEmployees <span class="code-keyword" style="border: 0px; color: blue; margin: 0px; padding: 0px;">WHERE</span> EmployeeID = @EmpID</code></pre>
<div style="font-size: 13.63636302947998px;">
<code style="border: 0px; font-size: 11pt; margin: 0px; padding: 0px;"><span style="font-family: inherit;">Here, in this example, you can clearly see the parameter <code style="border: 0px; font-size: 11pt; margin: 0px; padding: 0px;">@EmpID</code> is included in the statement. Finally, <code style="border: 0px; font-size: 11pt; margin: 0px; padding: 0px;">sp_executesql</code>takes the necessary information to do the parameter substitution and execute the dynamically built SQL string.</span></code></div>
<ol style="border: 0px; font-size: 13.63636302947998px; margin: 10px 0px; padding: 0px 0px 0px 40px;">
<li style="border: 0px; margin: 0px; padding: 0px;"><code style="border: 0px; font-size: 11pt; margin: 0px; padding: 0px;"><span style="font-family: inherit;"><code style="border: 0px; font-size: 11pt; margin: 0px; padding: 0px;">@SQLQuery</code> --> contains the SQL statement</span></code></li>
<li style="border: 0px; margin: 0px; padding: 0px;"><code style="border: 0px; font-size: 11pt; margin: 0px; padding: 0px;"><span style="font-family: inherit;"><code style="border: 0px; font-size: 11pt; margin: 0px; padding: 0px;">@ParameterDefinition</code> --> contains the Parameter Definition</span></code></li>
<li style="border: 0px; margin: 0px; padding: 0px;"><code style="border: 0px; font-size: 11pt; margin: 0px; padding: 0px;"><span style="font-family: inherit;"><code style="border: 0px; font-size: 11pt; margin: 0px; padding: 0px;">@EmpID</code> --> contains the parameter value to be substituted to the parameter in the SQL statement.</span></code></li>
</ol>
<div style="font-size: 13.63636302947998px;">
<code style="border: 0px; font-size: 11pt; margin: 0px; padding: 0px;"><span style="font-family: inherit;"><b style="border: 0px; margin: 0px; padding: 0px;">NOTE</b>: The parameters included in the Dynamic SQL string must have a corresponding entry in the Parameter Definition List and Parameter Value List.</span></code></div>
<div style="font-size: 13.63636302947998px;">
<code style="border: 0px; font-size: 11pt; margin: 0px; padding: 0px;"><span style="font-family: inherit;"><br /></span></code></div>
<div style="font-size: 13.63636302947998px;">
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-e2w1i8aEoHY/UKURnfr8c4I/AAAAAAAABho/FVavLzmOvC8/s1600/sqlserver_sql_server_2008_logo.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="263" src="http://2.bp.blogspot.com/-e2w1i8aEoHY/UKURnfr8c4I/AAAAAAAABho/FVavLzmOvC8/s320/sqlserver_sql_server_2008_logo.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-9tTIxPmd70Y/UKLG9NmKvbI/AAAAAAAABe4/nKn8pFu4F7w/s1600/evertonlima.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-9tTIxPmd70Y/UKLG9NmKvbI/AAAAAAAABe4/nKn8pFu4F7w/s1600/evertonlima.png" /></a></div>
<code style="border: 0px; font-size: 11pt; margin: 0px; padding: 0px;"><span style="font-family: inherit;"><br /></span></code></div>
<div style="font-size: 13.63636302947998px;">
<code style="border: 0px; font-size: 11pt; margin: 0px; padding: 0px;"><span style="font-family: inherit;"><br /></span></code></div>
<div style="color: #111111; font-size: 13.63636302947998px;">
</div>
</div>
</div>
</span></span></div>
</div>
<hr />
<span style="font-size: x-small;">Texto original em: <a href="http://www.codeproject.com/Articles/20815/Building-Dynamic-SQL-In-a-Stored-Procedure">http://www.codeproject.com/Articles/20815/Building-Dynamic-SQL-In-a-Stored-Procedure</a></span></div>
Everton Limahttp://www.blogger.com/profile/06038304424400850290noreply@blogger.com0R. Antônio de Paula Portes, 2-264 - Parque Residencial União, São José dos Campos - São Paulo, 12239-040, Brasil-23.266432861246336 -45.903056859970093-23.267344361246337 -45.904290859970089 -23.265521361246336 -45.901822859970096tag:blogger.com,1999:blog-2051968848006659883.post-48760263493514236052012-11-29T10:22:00.000-02:002012-11-30T19:34:27.290-02:00USANDO COLUNAS COMPUTADAS (USING COMPUTED COLUMNS)<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: left;">
</div>
<span style="font-family: inherit;">Em algumas bases de dados, alguns valores que foram calculados, muitas vezes geram diversos relatórios. Também existem algumas colunas que são dependentes de uma ou mais colunas. Quando uma coluna é atualizada, usa-se gatilhos para sincronizar os novos valores em colunas dependentes. É necessária a utilização de um meio mais eficiente e padronizado para lidar com esses tipos de cenários. Então como é possível se livrar da sobrecarga de cálculos em tempo de geração de relatórios e como evitar o uso de gatilhos para a sincronização de colunas atualizadas?</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;"><b>Solução:</b></span><br />
<span style="font-family: inherit;">Para esses cenários onde os valores calculados são necessárias ou valores são gerados através de manipulação em outras colunas, temos um poderoso recurso previsto no SQL Server. Este recurso é o de "Colunas computadas".</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">Uma coluna computada é calculada a partir de uma expressão que pode usar outra coluna ou colunas na mesma tabela. Funções, variáveis, constantes, nomes de colunas não computadas ou qualquer combinação de todos estes podem ser usados junto com as operadoras para criar uma coluna computada.</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">Nesta dica, vamos percorrer um exemplo de implementação de uma coluna computada.</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">Vamos testar scripts em SQL Server 2005 e SQL Server 2008. No script a seguir será criada uma tabela chamada CCtest no banco de dados AdventureWorks com três colunas [empNumb], [DOBirth], [DORetirement].</span><br />
<span style="font-family: inherit;"><br /></span>
Anexando o AdventureWorks baixado da Microsoft<br />
<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">USE [master]</span><br />
<span style="font-family: Courier New, Courier, monospace;">GO</span><br />
<span style="font-family: Courier New, Courier, monospace;">CREATE DATABASE [AdventureWorks2012] ON </span><br />
<span style="font-family: Courier New, Courier, monospace;">( FILENAME = N'D:\MSSQL\Data\AdventureWorks2012_Data.mdf' ),</span><br />
<span style="font-family: Courier New, Courier, monospace;">( FILENAME = N'D:\MSSQL\Data\AdventureWorks2012_log.ldf' )</span><br />
<span style="font-family: Courier New, Courier, monospace;"> FOR ATTACH</span><br />
<span style="font-family: Courier New, Courier, monospace;">GO</span><br />
<div>
<br /></div>
<span style="font-family: inherit;">Somos obrigados a ter a "Data de Aposentadoria" ([DORetirement]) para cada funcionário como (DOBirth + 60 anos - 1 dia). Em vez de calcular a cada vez que é chamado um relatório ou atualizar a coluna [DORetirement], executar um gatilho para quando o [DOBirth] é atualizado, temos uma melhor abordagem aqui criando [DORetirement] como uma coluna computada. Desde que esta regra pode ser mudada a qualquer momento estamos implementando-a como uma coluna computada em vez de um valor codificado.</span><br />
<span style="font-family: inherit;"><br /></span>
<br />
<span style="font-family: Courier New, Courier, monospace;">USE [AdventureWorks2012] </span><br />
<span style="font-family: Courier New, Courier, monospace;">GO </span><br />
<span style="font-family: Courier New, Courier, monospace;">CREATE TABLE [dbo].[CCtest]</span><br />
<span style="font-family: Courier New, Courier, monospace;">(</span><br />
<span style="font-family: Courier New, Courier, monospace;">[empNumb] [int] NULL,</span><br />
<span style="font-family: Courier New, Courier, monospace;">[DOBirth] [datetime] NULL,</span><br />
<span style="font-family: Courier New, Courier, monospace;">[DORetirement] AS (dateadd(year,(60),[DOBirth])-(1)) PERSISTED</span><br />
<span style="font-family: Courier New, Courier, monospace;">)</span><br />
<span style="font-family: Courier New, Courier, monospace;">GO</span><br />
<br />
Existe a possibilidade de criar a mesma tabela utilizando o SSMS, mas é muito bom manter em mente os códigos. Vamos prosseguir desta forma.<br />
<br />
<br />
Agora temos o nosso CCtest tabela com uma coluna computada. Da mesma forma, podemos adicionar uma coluna computada a qualquer tabela existente usando o "ALTER TABLE" comando ou abrir a tabela no modo de design usando SSMS e fazer as alterações.<br />
<br />
Vamos inserir alguns dados e executar uma consulta para testar a funcionalidade da coluna computada.<br />
<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">USE AdventureWorks2012</span><br />
<span style="font-family: Courier New, Courier, monospace;">GO</span><br />
<span style="font-family: Courier New, Courier, monospace;">INSERT INTO CCTest (empNumb, DOBirth)</span><br />
<span style="font-family: Courier New, Courier, monospace;">SELECT 30, '1985-12-13' UNION ALL</span><br />
<span style="font-family: Courier New, Courier, monospace;">SELECT 25, '1980-11-18 ' UNION ALL</span><br />
<span style="font-family: Courier New, Courier, monospace;">SELECT 21, '1978-01-19 ' UNION ALL</span><br />
<span style="font-family: Courier New, Courier, monospace;">SELECT 7, '1985-12-13 ' UNION ALL</span><br />
<span style="font-family: Courier New, Courier, monospace;">SELECT 5, '1975-07-23 '</span><br />
<span style="font-family: Courier New, Courier, monospace;">GO</span><br />
<span style="font-family: Courier New, Courier, monospace;">SELECT * FROM dbo.CCTest</span><br />
<span style="font-family: Courier New, Courier, monospace;">GO</span><br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-IuGboVUNUOY/ULdPdUwFVqI/AAAAAAAABjE/6C9g8_tUMTQ/s1600/FOTO1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="310" src="http://2.bp.blogspot.com/-IuGboVUNUOY/ULdPdUwFVqI/AAAAAAAABjE/6C9g8_tUMTQ/s320/FOTO1.png" width="320" /></a></div>
<br />
Para verificar se a coluna computada será atualizado para quaisquer atualizações, vamos atualizar [DOBirth] para [empNumb] 25.<br />
<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">UPDATE CCtest</span><br />
<span style="font-family: Courier New, Courier, monospace;">SET DOBirth = '1960-03-25'</span><br />
<span style="font-family: Courier New, Courier, monospace;">WHERE empnumb = 25</span><br />
<span style="font-family: Courier New, Courier, monospace;">GO</span><br />
<span style="font-family: Courier New, Courier, monospace;">SELECT * FROM dbo.CCTest</span><br />
<span style="font-family: Courier New, Courier, monospace;">WHERE Empnumb = 25</span><br />
<span style="font-family: Courier New, Courier, monospace;">GO</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-YPO5Y3oiB6g/ULdQQGege9I/AAAAAAAABjM/Bd7ygxdL04M/s1600/FOTO2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="308" src="http://2.bp.blogspot.com/-YPO5Y3oiB6g/ULdQQGege9I/AAAAAAAABjM/Bd7ygxdL04M/s320/FOTO2.png" width="320" /></a></div>
<br />
<br />
<b>Persistência (PERSISTED)</b><br />
Você deve ter notado que nós também usamos a propriedade "persisted" para a nossa coluna computada. Esta propriedade para colunas computadas foi introduzido no SQL Server 2005 e em diante. É importante para qualquer coluna computada, pois muitas características adicionais dependem dele. Para ser capaz de fazer uma coluna computada como persistentes que tem que ser determinista.<br />
<br />
<b>Aqui estão algumas regras:</b><br />
<br />
<ul style="text-align: left;">
<li>Se a propriedade PERSISTED não foi configurada então coluna calculada será apenas uma coluna virtual. Não há dados para esta coluna serão armazenados no disco e os valores serão calculados a cada momento que for referenciado em um script. Se esta propriedade é definida como ativa então os dados de coluna computada serão armazenados no disco, aumenta-se o espaço em disco, porém diminui a necessidade de processamento do servidor.</li>
<li>Qualquer atualização na coluna referenciada serão sincronizadas automaticamente na coluna computada se é ela persistente.</li>
<li>Junto com algumas outras condições em PERSISTED são necessárias para criar um índice na coluna computada.</li>
</ul>
<br />
<b>Nulidade(</b>Nullibility)<br />
Nullibility para um valor de coluna calculada será determinada pelo Engine do SQL em si. O resultado de uma coluna NOT NULL referenciado pode ser NULL em determinadas condições para evitar possíveis erros de excessão ou sobrecargas. É possível proporcionar um valor alternativo para NULL utilizando o ISNULL (check_expression, constante), se necessário.<br />
<br />
<b>Algumas limitações</b><br />
<br />
<ul style="text-align: left;">
<li>Para o SQL Server 2000 você não pode criar uma coluna computada persistente.</li>
<li>Você não pode fazer referência a colunas de outras tabelas para uma expressão de coluna computada.</li>
<li>Você não pode inserir ou atualizar declarações em colunas computadas.</li>
<li>Se você estiver combinando operadores de dois tipos diferentes de dados em sua expressão então o operador de menor precedência será convertido para o de maior precedência. Se a conversão implícita não for possível, então erro será gerado.</li>
<li>Uma subconsulta não pode ser usado como uma expressão para criar uma coluna computada.</li>
<li>As colunas computadas podem ser utilizadas em SELECT, WHERE ou ORDER BY e como expressões regulares, mas para usar uma coluna computada como chave CHECK, estrangeiros ou não restrições NULL você tem que configurá-lo para PERSISTED.</li>
<li>Para usar uma coluna computada como PRIMARY ou UNIQUE KEYdeve ser definido por uma expressão determinística e tipo de dados de expressão de coluna computada deve ser indexável.</li>
</ul>
<br />
<b>Próximos Passos</b><br />
<br />
<ul style="text-align: left;">
<li>Durante o planejamento para qualquer coluna computada, por favor, tenha em mente que, apesar de uma coluna computada persistente irá reduzir a sobrecarga para os cálculos em tempo de execução ele vai consumir mais espaço em disco.</li>
<li>Para obter nulidade de qualquer coluna computada em uma tabela, use a função COLUMNPROPERTY com a propriedade AllowsNull.</li>
<li>Criando índices em colunas computadas requer certas condições para ser cumprida. Para mais detalhes sobre essas condições visite <a href="http://msdn.microsoft.com/pt-br/library/ms189292(v=sql.90).aspx" target="_blank">BOL</a> (Books On Line)</li>
</ul>
<div>
Como sempre, não quero esgotar o assunto aqui, mas comentários e sugestões são bem vindas.</div>
<div>
<br /></div>
<div>
Até o próximo post!</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-e2w1i8aEoHY/UKURnfr8c4I/AAAAAAAABho/FVavLzmOvC8/s1600/sqlserver_sql_server_2008_logo.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="263" src="http://2.bp.blogspot.com/-e2w1i8aEoHY/UKURnfr8c4I/AAAAAAAABho/FVavLzmOvC8/s320/sqlserver_sql_server_2008_logo.png" width="320" /></a></div>
<br /></div>
Everton Limahttp://www.blogger.com/profile/06038304424400850290noreply@blogger.com0tag:blogger.com,1999:blog-2051968848006659883.post-11985499561831002542012-11-24T09:08:00.000-02:002012-11-24T09:08:39.155-02:00TRATAMENTO DE NULL (NULL IN FIELDS)<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
Uma query (SELECT) retorna do banco de dados todas as linhas para as quais a cláusula WHERE retorna True (verdadeiro). Muitos desenvolvedores se confundem assumindo que a consulta retornará todos os registros para os quais a cláusula WHERE retorne qualquer valor diferente de False (Falso). Isto é uma causa comum de relatórios incompletos.<br />
<br />
Para explicar a razão, considere que a linguagem SQL usa uma lógica de três valores: True, False e Null (Nulo). Qualquer valor Null em uma expressão torna toda a expressão Null (com algumas exceções citadas abaixo).<br />
<br />
Exemplo: O senso comum sugere que o SELECT abaixo retorne todas as linhas em uma tabela:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">SELECT * FROM Pedidos WHERE (total < 1000 Or total >= 1000)</span><br />
<br />
O SELECT não incluirá os registros para os quais o campo Total é Null, porque este valor faz com que toda a expressão contida na cláusula WHERE seja avaliada como Null.<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">SELECT * FROM Pedidos WHERE Total = 0</span><br />
<br />
A consulta acima retorna todos os pedidos para os quais Total é zero, mas não aqueles para os quais o Total é Null. Se você quer incluir estes últimos, precisa pesquisar explicitamente pelos valores Null:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">SELECT * FROM Pedidos WHERE total = 0 OR total IS NULL</span><br />
<br />
ISNULL é uma função T-SQL que é constantemente usada para lidar com valores Null. Simplesmente, ela sempre retorna o seu primeiro argumento exceto quando ele é Null (neste caso ela retorna o segundo argumento). Veja como você pode reescrever a consulta acima para lidar com valores Null:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">-- converte valores Null para zero antes de compará-los</span><br />
<span style="font-family: 'Courier New', Courier, monospace;">SELECT * FROM Pedidos WHERE ISNULL(total, 0) = 0 </span><br />
<br />
Além disto, a T-SQL estende o padrão ANSI 92 e suporta Null também em cláusulas IN, de modo que você pode reescrever a consulta acima como abaixo:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">SELECT * FROM Pedidos WHERE total IN (0, NULL)</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
Podemos, também, fazer a consulta inversa, procurando na tabela todos os registros cujo campo especificado seja diferente de Null.<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">SELECT * FROM Pedidos WHERE total IS NOT NULL</span><br />
<br />Agora, imagine se você quiser usar o comando CASE para testar os resultados com valor Null.<br /><br />x<br />1<br />2<br />NULL<br />4<br />5<br /><br />Este seria o método de entendimento direto de como fazer:<br /><span style="background-color: white; font-family: 'Courier New', Courier, monospace; line-height: 16.78333282470703px;"><br /></span><br />
<span style="font-family: Courier New, Courier, monospace;">SELECT x,</span><span style="font-family: 'Courier New', Courier, monospace;">CASE x</span><span style="font-family: Courier New, Courier, monospace;"><br /></span><span style="font-family: 'Courier New', Courier, monospace;">WHEN NULL THEN ‘sim’</span><span style="font-family: Courier New, Courier, monospace;"><br /></span><span style="font-family: 'Courier New', Courier, monospace;">ELSE ‘nao’</span><span style="font-family: Courier New, Courier, monospace;"><br /></span><span style="font-family: 'Courier New', Courier, monospace;">END AS resultado</span><span style="font-family: Courier New, Courier, monospace;"><br /></span><span style="font-family: 'Courier New', Courier, monospace;">FROM </span><span style="font-family: 'Courier New', Courier, monospace;">Tabela</span><span style="font-family: Courier New, Courier, monospace;"><br /></span><br />
<br />
O resultado esperado seria:<br />
<br />
x<span class="Apple-tab-span" style="white-space: pre;"> </span>resultado<br />
1<span class="Apple-tab-span" style="white-space: pre;"> </span>nao<br />
2<span class="Apple-tab-span" style="white-space: pre;"> </span>nao<br />
NULL<span class="Apple-tab-span" style="white-space: pre;"> </span>sim<br />
4<span class="Apple-tab-span" style="white-space: pre;"> </span>nao<br />
5<span class="Apple-tab-span" style="white-space: pre;"> </span>nao<br />
<br />
Mas ao invés disto teremos exatamente esse resultado:<br />
<br />
x<span class="Apple-tab-span" style="white-space: pre;"> </span>resultado<br />
1<span class="Apple-tab-span" style="white-space: pre;"> </span>nao<br />
2<span class="Apple-tab-span" style="white-space: pre;"> </span>nao<br />
NULL<span class="Apple-tab-span" style="white-space: pre;"> </span>nao<br />
4<span class="Apple-tab-span" style="white-space: pre;"> </span>nao<br />
5<span class="Apple-tab-span" style="white-space: pre;"> </span>nao<br />
<br />
Mas então, porque não funcionou? Eu respondo:<br />
NULL é desconhecido, NULL não é igual a NULL, e NULL é a "coisa" mais estranha que pode existir num banco de dados, comum sim, normal não.<br />
<br />
<br />
Este seria o código exato:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">SELECT x,</span><br />
<span style="font-family: Courier New, Courier, monospace;">CASE</span><br />
<span style="font-family: Courier New, Courier, monospace;">WHEN x IS NULL THEN ‘sim’</span><br />
<span style="font-family: Courier New, Courier, monospace;">ELSE ‘nao’</span><br />
<span style="font-family: Courier New, Courier, monospace;">END AS resultado</span><br />
<span style="font-family: Courier New, Courier, monospace;">FROM Tabela</span><br />
<br />
<br />
<br />
Espero que tirem proveito deste conhecimento. Até mais!<br />
<br />
<br />
</div>
Everton Limahttp://www.blogger.com/profile/06038304424400850290noreply@blogger.com0tag:blogger.com,1999:blog-2051968848006659883.post-11343552005104566932012-11-20T09:37:00.001-02:002012-11-20T15:43:42.385-02:00Campo de CNPJ usando notação científica (Scientific Notation for largue numbers)<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
Já tive vários problemas em realizar consultas em banco de dados com campo de CNPJ que gerassem outras tabelas, ou para relatório ou para concatenação de dados.<br />
Não vou postar aqui hoje as telas, mas apenas o código que utilizei para resolver o problema.<br />
<br />
<blockquote>
<table border="0" cellpadding="2" cellspacing="0" style="width: 541px;"> <tbody>
<tr> <td valign="top" width="539"><span style="font-family: Consolas;"> </span><br />
<div align="center">
<span style="font-family: Consolas;"><br />SELECT CAST(CAST(CNPJ AS NUMERIC) AS NVARCHAR(15)) FROM TABELA_DADOS</span></div>
</td></tr>
</tbody></table>
</blockquote>
<br />
A idéia aqui é Mudar o formato do campo para NUMERIC, deixando ele assim em “plain text” e depois Mudar novamente para NVARCHAR(15) para ficar texto. Eu sei que campos de CNPJ só tem 14 digitos, porém por segurança, sempre ponho esse byte a mais. Padrão meu, para os bancos de dados que tenho trabalhado esse byte “a mais” não tem afetado desempenho e nem feito aumentar de modo significativo meu banco de dados. <br />
<br />
<strong>Assim que eu tiver algumas telas para exemplificar, eu posto…</strong><br />
<a href="http://lh6.ggpht.com/-VCiqQok2fL8/UKtrXpDgsLI/AAAAAAAABik/Kt4TXUbhnww/s1600-h/sqlserver_sql_server_2008_logo%25255B3%25255D.png"><img alt="sqlserver_sql_server_2008_logo" height="197" src="http://lh3.ggpht.com/-2Hs9lcN2xMU/UKtrYi-F5yI/AAAAAAAABis/sqCNTRjXiWs/sqlserver_sql_server_2008_logo_thumb%25255B1%25255D.png?imgmax=800" style="display: block; float: none; margin-left: auto; margin-right: auto;" title="sqlserver_sql_server_2008_logo" width="240" /></a></div>
Everton Limahttp://www.blogger.com/profile/06038304424400850290noreply@blogger.com0tag:blogger.com,1999:blog-2051968848006659883.post-69515949123306900782012-11-17T21:22:00.001-02:002012-12-03T11:14:22.767-02:00Primeiro contato com SCRUM (Knowing Scrum)<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
Scrum é uma metodologia ágil para gestão e planejamento de projetos de software. Se você chegou até aqui interessado em fazer uma das certificações disponíveis para Scrum, veja por que dizemos não à certificação?<br />
No Scrum, os projetos são dividos em ciclos (tipicamente mensais) chamados deSprints. O Sprint representa um Time Box dentro do qual um conjunto de atividades deve ser executado. Metodologias ágeis de desenvolvimento de software são iterativas, ou seja, o trabalho é dividido em iterações, que são chamadas de Sprints no caso do Scrum.<br />
As funcionalidades a serem implementadas em um projeto são mantidas em uma lista que é conhecida como Product Backlog. No início de cada Sprint, faz-se um Sprint Planning Meeting, ou seja, uma reunião de planejamento na qual o Product Ownerprioriza os itens do Product Backlog e a equipe seleciona as atividades que ela será capaz de implementar durante o Sprint que se inicia. As tarefas alocadas em um Sprint são transferidas do Product Backlog para o Sprint Backlog.<br />
A cada dia de uma Sprint, a equipe faz uma breve reunião (normalmente de manhã), chamada Daily Scrum. O objetivo é disseminar conhecimento sobre o que foi feito no dia anterior, identificar impedimentos e priorizar o trabalho do dia que se inicia.<br />
Ao final de um Sprint, a equipe apresenta as funcionalidades implementadas em umaSprint Review Meeting. Finalmente, faz-se uma Sprint Retrospective e a equipe parte para o planejamento do próximo Sprint. Assim reinicia-se o ciclo. Veja a ilustração abaixo:<br />
<div class="separator" style="clear: both;">
<a href="http://1.bp.blogspot.com/-_zDSh8n9uY8/UKgY-kV9XYI/AAAAAAAABiI/MSnDpma4c80/s1600/ciclo_scrum.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="277" src="http://1.bp.blogspot.com/-_zDSh8n9uY8/UKgY-kV9XYI/AAAAAAAABiI/MSnDpma4c80/s400/ciclo_scrum.gif" width="400" /></a></div>
<div class="separator" style="clear: both;">
<a href="http://3.bp.blogspot.com/-f2FAw7L8BAQ/UKga0ZYL0MI/AAAAAAAABiQ/ha-xnDVp8uc/s1600/figura_scrum1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="http://3.bp.blogspot.com/-f2FAw7L8BAQ/UKga0ZYL0MI/AAAAAAAABiQ/ha-xnDVp8uc/s640/figura_scrum1.png" width="550" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
Resolvendo fazer o curso, eu recomendo o site <a href="http://tiexames.com.br/curso_Scrum_Master.php" target="_blank">http://tiexames.com.br/curso_Scrum_Master.php</a><br />
<br />
Site Oficial: <a href="http://www.scrum.org/assessments/" target="_blank">http://www.scrum.org/assessments/</a></div>
Everton Limahttp://www.blogger.com/profile/06038304424400850290noreply@blogger.com0tag:blogger.com,1999:blog-2051968848006659883.post-70345521874082491102012-11-17T16:05:00.001-02:002012-11-17T16:05:42.406-02:00Otimizar a comunicação entre áreas com o BPM é o segredo de uma gestão saudável (Optimizing follow-up with BMP)<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div style="font-size: 14px; line-height: 1.5em; text-align: justify;">
<span style="font-family: inherit;">Em entrevista recentemente compartilhada neste <a href="http://www.supravizio.com/Noticias/ArtMID/619/ArticleID/35/Os-beneficios-do-mapeamento-de-processos-para-a-gestao-da-qualidade.aspx" target="_blank">link</a>, Cassiana Bovo, especialista em gestão da qualidade estratégica e consultora empresarial, falou sobre a importância do Mapeamento de Processos na busca pela melhoria contínua das atividades executadas pelas empresas. Ela ressaltou que as empresas geralmente buscam o Mapeamento de Processos quando estão com sérios problemas de comunicação e que com a implantação da metodologia esses problemas podem ser evitados.</span></div>
<div style="font-size: 14px; line-height: 1.5em; text-align: justify;">
<span style="font-family: inherit;">Segundo Cassiana, as palavras comunicação e informatização têm sido nos últimos anos foco do mundo empresarial. “Os empresários, buscando <a href="http://www.profissionaisti.com.br/2012/11/improdutividade-x-gestao-de-processos-utilizando-bpm/" style="color: #2c78b9;" title="Improdutividade x Gestão de processos utilizando BPM">otimizar a produtividade</a>, encontram na informatização um meio de controlar, monitorar e agilizar o processo produtivo, seja ele no meio industrial, varejo e atacado ou serviços”, comenta a consultora.</span></div>
<div style="font-size: 14px; line-height: 1.5em; text-align: justify;">
<span style="font-family: inherit;">Atualmente a utilização de ferramentas BPM e de metodologias que agregam facilidades à sua implantação, como o Mapeamento de Processos, por exemplo, são alternativas que as empresas buscam a fim de otimizar seu trabalho e, a partir de um processo de melhoria contínua, alcançar bons resultados. “Uma tendência, que já é realidade nas grandes corporações, e está se tornando acessível às pequenas e médias empresas, é a implantação do <a href="http://www.profissionaisti.com.br/tag/bpm/" style="color: #2c78b9;">Mapeamento de Processos (BPM)</a> como ferramenta para reduzir as falhas de comunicação entre as diversas áreas das empresas”, explica Cassiana.</span></div>
<div style="font-size: 14px; line-height: 1.5em; text-align: justify;">
<span style="font-family: inherit;">De acordo com a especialista em gestão da qualidade, a utilização de uma ferramenta BPM deve estar intimamente ligada ao planejamento estratégico das empresas, para que possa ser efetiva na busca pela melhoria contínua dos processos realizados. “A adoção do BPM traz resultados significativos no tangente aos níveis tático e estratégico das organizações, independente de seu porte, pois roteiriza o caminho a ser percorrido (do processo), facilita o controle e monitoramento dos processos através de indicadores, promove a rápida detecção de não conformidades e melhorias reduzindo custos <a href="http://www.supravizio.com/Onde-aplicar.aspx" style="color: #2c78b9;">administrativos e produtivos</a>, evita que as informações se percam durante a realização das atividades da empresa e promove uma fácil visualização das responsabilidades e atribuições de cada setor”, completa.</span></div>
<div style="font-size: 14px; line-height: 1.5em; text-align: justify;">
<span style="font-family: inherit;">“O mapeamento de processos (BPM), por seus diversos benefícios, proporciona uma melhor organização e sistematização das atividades da empresa, assim como melhora a comunicação entre os indivíduos e setores, propiciando um ambiente favorável para uma gestão saudável e a obtenção de bons resultados”, finaliza Cassiana.</span></div>
<div style="font-size: 14px; line-height: 1.5em; text-align: justify;">
<em><span style="font-family: inherit;">Saiba mais sobre <a href="http://www.linkedin.com/pub/cassiana-bovo/24/715/a10" style="color: #2c78b9;" target="_blank">Cassiana Bovo</a>: Administradora, Consultora Empresarial e da Qualidade, Especialista em Gestão Estratégica e Qualidade, Cassiana Bovo é sócia da 3DK Comunicação e Consultoria; e Diretora de Negócios do Empresas S/A.</span></em></div>
<div style="font-size: 14px; line-height: 1.5em; text-align: justify;">
<em><span style="font-family: inherit;">Fonte: <a href="http://www.supravizio.com/Noticias.aspx" style="color: #2c78b9;">Blog Supravizio BPM</a></span></em></div>
</div>
Everton Limahttp://www.blogger.com/profile/06038304424400850290noreply@blogger.com0tag:blogger.com,1999:blog-2051968848006659883.post-11460934072734718142012-11-17T15:59:00.000-02:002012-11-17T15:59:24.562-02:00Crie cenários de redes mais complexas com o simulador GNS3 (Create a complex network with a simulator)<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div style="font-size: 14px; line-height: 1.5em; text-align: justify;">
<span style="font-family: inherit;">Todos conhecem o Packet Tracer, que na minha opinião é um excelente simulador e deve ser utilizado por todos aqueles que estão começando seus estudos ou se preparando para o exame do <a href="http://www.profissionaisti.com.br/2011/04/qual-o-mercado-de-trabalho-para-um-profissional-certificado-ccna/" style="color: #2c78b9;" title="Qual o mercado de trabalho para um profissional certificado CCNA?">CCNA</a>. No entanto, para aqueles que estão estudando para um nível mais avançado o Packet Tracer não atende a todas as necessidades, pois cenários de redes mais complexas não podem ser criados no Packet Tracer.</span></div>
<div style="font-size: 14px; line-height: 1.5em; text-align: justify;">
<span style="font-family: inherit;">Então, se você está estudando para algum exame Cisco depois do <a href="http://www.profissionaisti.com.br/2011/04/qual-o-mercado-de-trabalho-para-um-profissional-certificado-ccna/" style="color: #2c78b9;" title="Qual o mercado de trabalho para um profissional certificado CCNA?">CCNA</a> quais caminhos pode tomar:</span></div>
<ol style="font-size: 12px; line-height: 18px; text-align: justify;">
<li style="font-size: 14px; line-height: 1.5em;"><span style="font-family: inherit;">Montar um lab próprio, com equipamentos reais, em sua casa. Para aqueles que possuem uma boa situação financeira até pode ser um bom caminho, mas no final o custo acaba não sendo nada barato.</span></li>
<li style="font-size: 14px; line-height: 1.5em;"><span style="font-family: inherit;">Procurar por empresas que aluguem laboratórios para estudo. Essa pode ser uma tarefa dificil, pois aqui no Brasil esse tipo de serviço não é muito comum, além da incoveniência de ter que estudar com hora marcada e tempo de acesso limitado.</span></li>
<li style="font-size: 14px; line-height: 1.5em;"><span style="font-family: inherit;">Essa é a minha preferida – utilizar o simulador de redes GNS3.</span></li>
</ol>
<h3 style="border-bottom-color: rgb(239, 239, 239); border-bottom-style: solid; border-bottom-width: 2px; clear: both; color: #737373; font-size: 17px; font-weight: normal; line-height: 18px; margin: 10px 0px; padding: 6px 0px; text-align: justify; text-shadow: white 1px 1px;">
<span style="font-family: inherit;">Mas o que é o GNS3?</span></h3>
<div style="font-size: 14px; line-height: 1.5em; text-align: justify;">
<span style="font-family: inherit;">O simulador GNS3 é um software grátis (isso mesmo, grátis), open source, e que pode ser baixado e utilizado livremente. O GNS3 funciona com imagens IOS da <a href="http://www.profissionaisti.com.br/2011/03/como-conseguir-aumento-de-salario-com-certificacoes-cisco/" style="color: #2c78b9;" title="Como conseguir aumento de salário com Certificações Cisco">Cisco</a> reais, que são emuladas através de um programa chamado <a href="http://en.wikipedia.org/wiki/Dynamips" style="color: #2c78b9;" target="_blank">Dynamips</a>. Podemos dizer que o GNS3 é a interface gráfica para o Dynamips, que é o programa que faz todo o trabalho pesado de emular os equipamentos utilizando IOS reais da Cisco.</span></div>
<div style="font-size: 14px; line-height: 1.5em; text-align: justify;">
<span style="font-family: inherit;">Com sua interface gráfica intuitiva e bem fácil de se utilizar o GNS3 se mostra como uma poderosa ferramenta, capaz de emular redes complexas e que pode ser utilizada por todos aqueles que estejam em busca de uma certificação avançada da Cisco.</span></div>
<h3 style="border-bottom-color: rgb(239, 239, 239); border-bottom-style: solid; border-bottom-width: 2px; clear: both; color: #737373; font-size: 17px; font-weight: normal; line-height: 18px; margin: 10px 0px; padding: 6px 0px; text-align: justify; text-shadow: white 1px 1px;">
<span style="font-family: inherit;">O que podemos fazer com o GNS3</span></h3>
<div style="font-size: 14px; line-height: 1.5em; text-align: justify;">
<span style="font-family: inherit;">De acordo com o website do GNS3 veja algumas das características desse poderoso simulador:</span></div>
<ul style="font-size: 12px; line-height: 18px; text-align: justify;">
<li style="background-image: url(http://www.profissionaisti.com.br/wp-content/themes/pti2011/images/bullet.gif); background-position: 0px 7px; background-repeat: no-repeat no-repeat; font-size: 14px; line-height: 1.5em; list-style: none; padding: 0px 0px 6px 8px;"><span style="font-family: inherit;">Design de topologias de redes complexas</span></li>
<li style="background-image: url(http://www.profissionaisti.com.br/wp-content/themes/pti2011/images/bullet.gif); background-position: 0px 7px; background-repeat: no-repeat no-repeat; font-size: 14px; line-height: 1.5em; list-style: none; padding: 0px 0px 6px 8px;"><span style="font-family: inherit;">Emulação de muitas plataformas de roteadores Cisco router e PIX firewall</span></li>
<li style="background-image: url(http://www.profissionaisti.com.br/wp-content/themes/pti2011/images/bullet.gif); background-position: 0px 7px; background-repeat: no-repeat no-repeat; font-size: 14px; line-height: 1.5em; list-style: none; padding: 0px 0px 6px 8px;"><span style="font-family: inherit;">Simulação de switches ethernet simples, ATM e Frame Relay</span></li>
<li style="background-image: url(http://www.profissionaisti.com.br/wp-content/themes/pti2011/images/bullet.gif); background-position: 0px 7px; background-repeat: no-repeat no-repeat; font-size: 14px; line-height: 1.5em; list-style: none; padding: 0px 0px 6px 8px;"><span style="font-family: inherit;">Conexão da rede simulado com o mundo real</span></li>
<li style="background-image: url(http://www.profissionaisti.com.br/wp-content/themes/pti2011/images/bullet.gif); background-position: 0px 7px; background-repeat: no-repeat no-repeat; font-size: 14px; line-height: 1.5em; list-style: none; padding: 0px 0px 6px 8px;"><span style="font-family: inherit;">Captura de pacotes utilizando o Wireshark</span></li>
</ul>
<h3 style="border-bottom-color: rgb(239, 239, 239); border-bottom-style: solid; border-bottom-width: 2px; clear: both; color: #737373; font-size: 17px; font-weight: normal; line-height: 18px; margin: 10px 0px; padding: 6px 0px; text-align: justify; text-shadow: white 1px 1px;">
<span style="font-family: inherit;">Plataformas Suportadas pelo GNS3</span></h3>
<div style="font-size: 14px; line-height: 1.5em; text-align: justify;">
<span style="font-family: inherit;">Na lista a seguir, citamos algumas das plataformas atualmente suportadas pelo GNS3. Como você pode notar, podemos utilizar uma grande quantidade de equipamentos para construir topologias complexas com o GNS3.</span></div>
<ul style="font-size: 12px; line-height: 18px; text-align: justify;">
<li style="background-image: url(http://www.profissionaisti.com.br/wp-content/themes/pti2011/images/bullet.gif); background-position: 0px 7px; background-repeat: no-repeat no-repeat; font-size: 14px; line-height: 1.5em; list-style: none; padding: 0px 0px 6px 8px;"><span style="font-family: inherit;">1710, 1720, 1721, 1750, 1751, 1760</span></li>
<li style="background-image: url(http://www.profissionaisti.com.br/wp-content/themes/pti2011/images/bullet.gif); background-position: 0px 7px; background-repeat: no-repeat no-repeat; font-size: 14px; line-height: 1.5em; list-style: none; padding: 0px 0px 6px 8px;"><span style="font-family: inherit;">2610, 2610XM, 2611, 2611XM, 2620, 2620XM, 2621, 2621XM, 2650XM, 2651XM, 2691</span></li>
<li style="background-image: url(http://www.profissionaisti.com.br/wp-content/themes/pti2011/images/bullet.gif); background-position: 0px 7px; background-repeat: no-repeat no-repeat; font-size: 14px; line-height: 1.5em; list-style: none; padding: 0px 0px 6px 8px;"><span style="font-family: inherit;">3620, 3640, 3660, 3725, 3745</span></li>
<li style="background-image: url(http://www.profissionaisti.com.br/wp-content/themes/pti2011/images/bullet.gif); background-position: 0px 7px; background-repeat: no-repeat no-repeat; font-size: 14px; line-height: 1.5em; list-style: none; padding: 0px 0px 6px 8px;"><span style="font-family: inherit;">7200</span></li>
</ul>
<h3 style="border-bottom-color: rgb(239, 239, 239); border-bottom-style: solid; border-bottom-width: 2px; clear: both; color: #737373; font-size: 17px; font-weight: normal; line-height: 18px; margin: 10px 0px; padding: 6px 0px; text-align: justify; text-shadow: white 1px 1px;">
<span style="font-family: inherit;">Utilizando o Simulador de Redes GNS3</span></h3>
<div style="font-size: 14px; line-height: 1.5em; text-align: justify;">
<span style="font-family: inherit;">Abaixo mostramos algumas telas do GNS3, apenas para vocês terem uma breve idéia de como é essa ferramenta.</span></div>
<div style="font-size: 14px; line-height: 1.5em; text-align: justify;">
<span style="font-family: inherit;">Essa primeira figura mostra a tela inicial do programa. No lado esquerdo da tela temos todos os equipamentos que poderão ser utilizados. Basta clicar e arrastar para área principal central, onde a topologia será construida.</span></div>
<div style="font-size: 14px; line-height: 1.5em; text-align: justify;">
<a href="http://www.dltec.com.br/blog/wp-content/uploads/2011/05/gns3-13.png" style="color: #2c78b9;"><span style="font-family: inherit;"><img alt="" class="alignnone size-full wp-image-902" height="432" src="http://www.dltec.com.br/blog/wp-content/uploads/2011/05/gns3-13.png" style="border: none; margin: 0px; padding: 0px;" title="gns3-1" width="580" /></span></a></div>
<div style="font-size: 14px; line-height: 1.5em; text-align: justify;">
<span style="font-family: inherit;">Abaixo temos um breve exemplo de uma topologia com 3 roteadores em uma rede Frame-Relay.</span></div>
<div style="font-size: 14px; line-height: 1.5em; text-align: justify;">
<span style="font-family: inherit;"><img alt="" class="alignnone size-full wp-image-903" height="432" src="http://www.dltec.com.br/blog/wp-content/uploads/2011/05/gns3-2.png" style="border: none; margin: 0px; padding: 0px;" title="gns3-2" width="580" /></span></div>
<div style="font-size: 14px; line-height: 1.5em; text-align: justify;">
<span style="font-family: inherit;">Por último mostramos um saída do comando show run em um dos roteadores.</span></div>
<div style="font-size: 14px; line-height: 1.5em; text-align: justify;">
<span style="font-family: inherit;"><img alt="" class="alignnone size-full wp-image-904" height="421" src="http://www.dltec.com.br/blog/wp-content/uploads/2011/05/gns3-3.png" style="border: none; margin: 0px; padding: 0px;" title="gns3-3" width="580" /></span></div>
<h3 style="border-bottom-color: rgb(239, 239, 239); border-bottom-style: solid; border-bottom-width: 2px; clear: both; color: #737373; font-size: 17px; font-weight: normal; line-height: 18px; margin: 10px 0px; padding: 6px 0px; text-align: justify; text-shadow: white 1px 1px;">
<span style="font-family: inherit;">Considerações Finais</span></h3>
<div style="font-size: 14px; line-height: 1.5em; text-align: justify;">
<span style="font-family: inherit;">Como podemos notar é possível fazer muita coisa com o GNS3. Você será capaz de montar topologias diversas, com diferentes níveis de complexidade e com as características necessárias para o exame de certificação específico que estiver estudando.</span></div>
<div style="font-size: 14px; line-height: 1.5em; text-align: justify;">
<span style="font-family: inherit;">Mas como tudo na vida, temos o lado bom e o lado ruim. Um dos principais pontos negativos é que você irá precisar de IOS Cisco reais. O GNS3 não vem com imagens IOS embutidas no simulador, ou seja, você deverá ter disponível os IOS que irá utilizar e informar o caminho da pasta para o GNS3, caso contrário o simulador não irá funcionar.</span></div>
<div style="font-size: 14px; line-height: 1.5em; text-align: justify;">
<span style="font-family: inherit;">Para baixar essas imagens diretamente do site da Cisco você deverá possuir uma conta CCO. É claro que existem outras fontes de onde conseguir imagens IOS da Cisco, mas definitivamente nós não recomendamos essa alternativa. O recomendado é que você realmente utilize imagens IOS baixadas diretamente da Cisco.</span></div>
<div style="font-size: 14px; line-height: 1.5em; text-align: justify;">
<span style="font-family: inherit;">Outro ponto importante é a quantidade de recurso de CPU e memória RAM consumidos ao se utilizar GNS3. Quanto mais complexa a topologia montada, maior quantidade de memória e CPU será consumida. Portanto, saiba que para rodar esse simulador será necessário um computador com uma certa robustez.</span></div>
<div style="font-size: 14px; line-height: 1.5em; text-align: justify;">
<span style="font-family: inherit;">Portanto é isso aí… utilizem que vale a pena! E em breve vamos postar mais artigos sobre o GNS3 e algumas de suas facilidades.</span></div>
<div style="font-size: 14px; line-height: 1.5em; text-align: justify;">
<span style="font-family: inherit;">Fonte: <a href="http://www.dltec.com.br/blog/redes-cisco/2011/05/22/simulador-de-redes-gns3/?preview=true&preview_id=894&preview_nonce=80de2f0b35" style="color: #2c78b9;" target="_blank">Blog da DlteC</a></span></div>
</div>
Everton Limahttp://www.blogger.com/profile/06038304424400850290noreply@blogger.com0tag:blogger.com,1999:blog-2051968848006659883.post-20251152753581700762012-11-16T11:42:00.000-02:002012-11-16T11:45:48.431-02:00Conhecendo o LUA (Knowing LUA, The programming language)<div dir="ltr" style="text-align: left;" trbidi="on">
Conversando com um colega programador, grande Danilo Nader, que me indicou conhecer algo do LUA (<a href="http://www.lua.org/">http://www.lua.org</a>).<br />
<blockquote class="tr_bq">
<span style="font-family: inherit;"><span style="background-color: white; text-align: justify;">Lua é inteiramente projetada, implementada e desenvolvida no Brasil, por uma </span><a href="http://www.lua.org/authors.html" style="background-color: white; color: navy; text-align: justify; text-decoration: initial;">equipe</a><span style="background-color: white; text-align: justify;"> na </span><a href="http://www.puc-rio.br/" style="background-color: white; color: navy; text-align: justify; text-decoration: initial;">PUC-Rio</a><span style="background-color: white; text-align: justify;">(Pontifícia Universidade Católica do Rio de Janeiro)</span></span></blockquote>
<br />
A linguagem conta com ambiente em Shell Script, tem para Windows e Linux.<br />
Pode-se utilizar, inclusive a versão de Framework para WEB, o Orbit (<a href="http://keplerproject.github.com/orbit/">http://keplerproject.github.com/orbit/</a>).<br />
<br />
Uma utilização bem aplicável é para dispositivos móveis. Ela interagem bem com o Java e o C#.<br />
<br />
Vamos dar continuidade nos estudos, e tão logo tenhamos algum tutorial, será postado e comentado.<br />
<br />
Até lá, (no Lua eh claro...)<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-juetPcimmEI/UKZDKF_u66I/AAAAAAAABh4/Hy1PJ2tcqAI/s1600/lua.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-juetPcimmEI/UKZDKF_u66I/AAAAAAAABh4/Hy1PJ2tcqAI/s1600/lua.gif" /></a></div>
<br /></div>
Everton Limahttp://www.blogger.com/profile/06038304424400850290noreply@blogger.com0tag:blogger.com,1999:blog-2051968848006659883.post-33173859434879006322012-11-15T13:54:00.000-02:002012-11-15T14:00:38.813-02:00Renomeando Colunas e Tabelas (How to Rename a Column Name or Table Name)<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="tr_bq">
Vamos usar o comando <span style="font-family: inherit;"><a href="http://msdn.microsoft.com/pt-br/library/ms188351.aspx" target="_blank">sp_rename (Transact-SQL)</a></span></div>
<br />
<h3 style="text-align: left;">
Observações:</h3>
<blockquote class="tr_bq">
<span style="font-family: inherit;"><span class="sentence" data-guid="ed5c57c39cbfe5065d7236e4e3f93f51" data-source="Changes the name of a user-created object in the current database." id="mt1" style="font-size: 13px;" xml:space="preserve">
<sentencetext xmlns="http://www.w3.org/1999/xhtml">Altera o nome de um objeto criado pelo usuário no banco de dados atual.</sentencetext>
</span><span class="sentence" data-guid="f117ca20f242bbd7f44bad660c7cf42e" data-source="This object can be a table, index, column, alias data type, or Microsoft .NET Framework common language runtime (CLR) user-defined type." id="mt2" style="font-size: 13px;" xml:space="preserve">Esse objeto pode ser uma tabela, índice, coluna, tipo de dados de alias ou tipo de dados CLR definido pelo usuário do Microsoft .NET Framework Common Language Runtime.</span></span></blockquote>
<h3 style="text-align: left;">
Sintaxe:</h3>
<blockquote>
sp_rename [ @objname = ] 'object_name' , [ @newname = ] 'new_name' [ , [ @objtype = ] 'object_type' ]</blockquote>
<h3>
Exemplos:</h3>
<h4>
A.Renomeando uma tabela</h4>
<br />
<div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px;" xmlns="http://www.w3.org/1999/xhtml">
<span class="sentence" data-guid="9075b182ce44568ec4315ebdbb7c1c25" data-source="The following example renames the <span class="code">SalesTerritory</span> table to <span class="code">SalesTerr</span> in the <span class="code">Sales</span> schema." id="mt52" xml:space="preserve">O exemplo a seguir renomeia a tabela <span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;" xmlns="http://www.w3.org/1999/xhtml">SalesTerritory</span> como <span class="code" style="background: white; color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;" xmlns="http://www.w3.org/1999/xhtml">SalesTerr</span> no esquema <span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;" xmlns="http://www.w3.org/1999/xhtml">Sales</span>.</span><br />
<div class="codeSnippetContainer" id="code-snippet-2" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml">
<div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;">
</div>
<div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; position: relative; top: -3px;">
<div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;">
<div class="codeSnippetToolBarText" style="float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;">
</div>
</div>
<div class="codeSnippetContainerCode" id="CodeSnippetContainerCode_5fca3a62-b77f-49a4-b40a-4e2be30a86e0" style="padding: 9px 21px; width: auto;">
<div style="background-color: white; padding: 0px;">
<pre style="font-family: Consolas, Courier, monospace; overflow: auto; padding: 5px; word-break: break-all; word-wrap: break-word;">USE AdventureWorks2012;
GO
EXEC sp_rename 'Sales.SalesTerritory', 'SalesTerr';
GO
</pre>
</div>
</div>
</div>
</div>
</div>
<h4>
B.Renomeando uma coluna</h4>
<div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px;" xmlns="http://www.w3.org/1999/xhtml">
<span class="sentence" data-guid="733725eea2c322824bbc1c57f001e3c9" data-source="The following example renames the <span class="code">TerritoryID</span> column in the <span class="code">SalesTerritory </span>table to <span class="code">TerrID</span>." id="mt53" xml:space="preserve">O exemplo a seguir renomeia a coluna <span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;" xmlns="http://www.w3.org/1999/xhtml">TerritoryID</span> na tabela <span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;" xmlns="http://www.w3.org/1999/xhtml">SalesTerritory </span>como <span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;" xmlns="http://www.w3.org/1999/xhtml">TerrID</span>.</span><br />
<div class="codeSnippetContainer" id="code-snippet-3" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml">
<div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;">
</div>
<div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; position: relative; top: -3px;">
<div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;">
<div class="codeSnippetToolBarText" style="float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;">
</div>
</div>
<div class="codeSnippetContainerCode" id="CodeSnippetContainerCode_b737ce6f-f3e9-49f6-bb0e-32dd977fda5c" style="padding: 9px 21px; width: auto;">
<div style="background-color: white; padding: 0px;">
<pre style="font-family: Consolas, Courier, monospace; overflow: auto; padding: 5px; word-break: break-all; word-wrap: break-word;">USE AdventureWorks2012;
GO
EXEC sp_rename 'Sales.SalesTerritory.TerritoryID', 'TerrID', 'COLUMN';
GO
</pre>
</div>
</div>
</div>
</div>
</div>
<h4>
C.Renomeando um índice</h4>
<div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px;" xmlns="http://www.w3.org/1999/xhtml">
<span class="sentence" data-guid="62af3e79d9350c3910aeec4c57c1c80d" data-source="The following example renames the <span class="code">IX_ProductVendor_VendorID</span> index to <span class="code">IX_VendorID</span>." id="mt54" xml:space="preserve">O exemplo a seguir renomeia o índice <span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;" xmlns="http://www.w3.org/1999/xhtml">IX_ProductVendor_VendorID</span> como <span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;" xmlns="http://www.w3.org/1999/xhtml">IX_VendorID</span>.</span><br />
<div class="codeSnippetContainer" id="code-snippet-4" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml">
<div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;">
</div>
<div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; position: relative; top: -3px;">
<div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;">
<div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;">
</div>
</div>
<div class="codeSnippetContainerCode" id="CodeSnippetContainerCode_369b9491-6238-481a-99d4-ea6f3e7b984a" style="padding: 9px 21px; width: auto;">
<div style="background-color: white; padding: 0px;">
<pre style="font-family: Consolas, Courier, monospace; overflow: auto; padding: 5px; word-break: break-all; word-wrap: break-word;">USE AdventureWorks2012;
GO
EXEC sp_rename N'Purchasing.ProductVendor.IX_ProductVendor_VendorID', N'IX_VendorID', N'INDEX';
GO
</pre>
</div>
</div>
</div>
</div>
</div>
<h4>
D.Renomeando um tipo de dados de alias</h4>
<div class="subsection" style="font-family: 'Segoe UI', Verdana, Arial; font-size: 13px;" xmlns="http://www.w3.org/1999/xhtml">
<span class="sentence" data-guid="108569adadc8422f280d965cf757b2eb" data-source="The following example renames the <span class="code">Phone</span> alias data type to <span class="code">Telephone</span>." id="mt55" xml:space="preserve">O exemplo a seguir renomeia o tipo de dados de alias <span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;" xmlns="http://www.w3.org/1999/xhtml">Phone</span> como <span class="code" style="color: #000066; font-family: monospace, 'Courier New', Courier; font-size: 14px;" xmlns="http://www.w3.org/1999/xhtml">Telephone</span>.</span><br />
<div class="codeSnippetContainer" id="code-snippet-5" style="min-width: 260px;" xmlns="http://www.w3.org/1999/xhtml">
<div class="codeSnippetContainerTabs" style="font-size: 10pt !important; height: 22px; position: relative; vertical-align: middle; z-index: 1;">
</div>
<div class="codeSnippetContainerCodeContainer" style="border-bottom-color: rgb(229, 229, 229); border-bottom-style: solid; border-bottom-width: 3px; border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 1px; clear: both; position: relative; top: -3px;">
<div class="codeSnippetToolBar" style="border-left-color: rgb(187, 187, 187); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(229, 229, 229); border-right-style: solid; border-right-width: 3px; border-top-color: rgb(229, 229, 229); border-top-style: solid; border-top-width: 3px; height: auto; width: auto;">
<div class="codeSnippetToolBarText" style="background-color: white; float: right; height: 0px; padding-left: 4px; padding-right: 4px; position: relative; top: -8px; vertical-align: top; width: auto;">
</div>
</div>
<div class="codeSnippetContainerCode" dir="ltr" id="CodeSnippetContainerCode_cab303e3-e6f8-473d-99e2-e2bb70261c01" style="background: white; padding: 9px 21px; width: auto;">
<div style="background-color: white; padding: 0px;">
<pre style="font-family: Consolas, Courier, monospace; overflow: auto; padding: 5px; word-break: break-all; word-wrap: break-word;">USE AdventureWorks2012;
GO
EXEC sp_rename N'Phone', N'Telephone', N'USERDATATYPE';
<span style="font-family: Consolas, Courier, monospace; font-size: 13px;">GO</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<br />
<br />
<h3>
Observações Importantes:</h3>
<br />
<span style="font-family: inherit;">Você só pode alterar o nome de um objeto ou tipo de dados no banco de dados atual. Os nomes da maioria dos tipos de dados do sistema e objetos do sistema não podem ser alterados.</span><span style="font-family: inherit;"><br />
<br />
sp_rename renomeia automaticamente o índice associado sempre que uma restrição PRIMARY KEY ou UNIQUE é renomeada. Se um índice renomeado for vinculado a uma restrição PRIMARY KEY, a restrição PRIMARY KEY também será renomeada automaticamente por sp_rename.<br />
<br />
sp_rename pode ser usado para renomear índices XML primários e secundários.<br />
<br />
Renomear um STORE PROICEDURE, FUCNTION, VIEW ou TRIGGER não alterará o nome do objeto correspondente na coluna definition da exibição de catálogo <a href="http://msdn.microsoft.com/pt-br/library/ms175081.aspx">sys.sql_modules</a>. Portanto, é recomendável que sp_rename não seja usado para renomear esses tipos de objetos. Em vez disso, cancele e recrie o objeto com o nome novo.<br />
<br />
A renomeação de um objeto, como uma tabela ou coluna, não renomeará automaticamente as referências a esse objeto. É necessário modificar manualmente todos os objetos que fazem referência ao objeto renomeado. Por exemplo, se você renomear uma coluna de tabela e aquela coluna for referenciada em uma TRIGGER, será necessário modificar a TRIGGER para que ele reflita o nome novo da coluna. Use <a href="http://msdn.microsoft.com/pt-br/library/bb677315.aspx">sys.sql_expression_dependencies</a> para listar dependências no objeto antes de renomeá-lo.</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-e2w1i8aEoHY/UKURnfr8c4I/AAAAAAAABho/FVavLzmOvC8/s1600/sqlserver_sql_server_2008_logo.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-e2w1i8aEoHY/UKURnfr8c4I/AAAAAAAABho/FVavLzmOvC8/s1600/sqlserver_sql_server_2008_logo.png" height="263" width="320" /></a></div>
</div>
Everton Limahttp://www.blogger.com/profile/06038304424400850290noreply@blogger.com0tag:blogger.com,1999:blog-2051968848006659883.post-21581718013439826252012-11-14T21:48:00.000-02:002012-11-14T21:48:11.092-02:00Licenciando o SQL Server 2012 (Licence in SQL SERVER 2012)<span style="color: #4e4e4e; font-size: 10.5pt; line-height: 15.75pt;"><span style="font-family: inherit;">O SQL Server 2012 é muito mais do que um SGBD (sistema de gerenciamento
de banco de dados) hoje ele é uma plataforma de dados e informação pronta!!!</span></span><br />
<div class="MsoNormal" style="line-height: 15.75pt; margin-bottom: .0001pt; margin-bottom: 0cm; vertical-align: baseline;">
<span style="font-family: inherit;"><b><u><span style="color: #4e4e4e; font-size: 10.5pt; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: PT-BR;">Com isso o SQL Server 2012 traz três principais pilares: </span></u></b><span style="color: #4e4e4e; font-size: 10.5pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: PT-BR;"><o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: 14.25pt; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 30.0pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: inherit;"><span style="color: #4e4e4e; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol; mso-fareast-language: PT-BR;">·<span style="font-size: 7pt; line-height: normal;">
</span></span><!--[endif]--><b><i><span style="color: #4e4e4e; font-size: 10.0pt; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: PT-BR;">Missão
Crítica:</span></i></b><b><i><span style="border: none windowtext 1.0pt; color: #4e4e4e; font-size: 10.0pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: PT-BR; padding: 0cm;"><br />
</span></i></b><span style="color: #4e4e4e; font-size: 10.0pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: PT-BR;">Provando a robustez do SQL Server para trabalhar em
ambientes de missão crítica, considerando performance , alta disponibilidade e
segurança umas das principais inovações são: AlwaysOn e ColumnStore Index.<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: 14.25pt; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 30.0pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: inherit;"><span style="color: #4e4e4e; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol; mso-fareast-language: PT-BR;">·<span style="font-size: 7pt; line-height: normal;">
</span></span><!--[endif]--><b><i><span style="color: #4e4e4e; font-size: 10.0pt; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: PT-BR;">Breakthrough
Insight:</span></i></b><b><i><span style="border: none windowtext 1.0pt; color: #4e4e4e; font-size: 10.0pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: PT-BR; padding: 0cm;"><br />
</span></i></b><span style="color: #4e4e4e; font-size: 10.0pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: PT-BR;">Inovando com uma solução de BI que é para todos
dentro da organização e permitindo através de poderosas ferramentas o acesso
aos dados em qualquer lugas a qualquer hora e no formato correto, dentro deste
pilar temos grandes inovações para a exploração e descoberta de dados com o
PowerView e o PowerPivot.<br />
Além de toda a parte de gerenciamento e disseminação dos dados com o SharePoint
e agora através de um único modelo semântico de dados temos o BI Semantic
Model.<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: 14.25pt; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 30.0pt; margin-right: 0cm; margin-top: 0cm; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt; text-indent: -18.0pt; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: inherit;"><span style="color: #4e4e4e; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol; mso-fareast-language: PT-BR;">·<span style="font-size: 7pt; line-height: normal;">
</span></span><!--[endif]--><b><i><span style="color: #4e4e4e; font-size: 10.0pt; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: PT-BR;">Cloud
On Your Terms:</span></i></b><b><i><span style="border: none windowtext 1.0pt; color: #4e4e4e; font-size: 10.0pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-border-alt: none windowtext 0cm; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: PT-BR; padding: 0cm;"><br />
</span></i></b><span style="color: #4e4e4e; font-size: 10.0pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: PT-BR;">Dentro deste pilar vc encontra a flexibilidade de
estender soluções desenvolvidas em casa até datacenter ou cloud e ainda
aumentar a sua produtividade com o SQL Server Data Tools que lhe permitirá
desenvolver uma única vez e executar em qualquer lugar, vale a pena tb
ressaltar a flexibilidade de sincronização dos dados de casa com dados que
estaja na nuvem através do Data Sync permitindo trabalhar ambientes híbridos.<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: 15.75pt; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 12.0pt; vertical-align: baseline;">
<span style="color: #4e4e4e; font-family: inherit; font-size: 10.5pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: PT-BR;">O SQL Server 2012 será comercializado em três edições principais:<o:p></o:p></span></div>
<h3>
<span style="font-family: inherit;"><span style="color: #4e4e4e; font-size: 10.5pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: PT-BR;"> </span><span style="font-size: 10.5pt;"><span style="color: #0071bb;">SQL SERVER 2012 ENTERPRISE</span></span></span></h3>
<div class="MsoNormal" style="line-height: 15.75pt; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 12.0pt; text-align: justify; vertical-align: baseline;">
<span style="color: #4e4e4e; font-family: inherit; font-size: 10.5pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: PT-BR;">As funcionalidades da antiga edição SQL Server 2008
R2 Datacenter estão disponíveis nesta, todas as features de BI, alta
disponibilidade, segurança e performance, é a edição mais parruda, ou
seja, tem todas as funcionalidades que o produto possui.<o:p></o:p></span></div>
<h3>
<span style="color: #0071bb;"><span style="font-family: inherit; font-size: 14px;">SQL SERVER 2012 BUSINESS INTELLIGENCE</span></span></h3>
<div class="MsoNormal" style="line-height: 15.75pt; margin-bottom: 12.0pt; margin-left: 0cm; margin-right: 0cm; margin-top: 12.0pt; text-align: justify; vertical-align: baseline;">
<span style="color: #4e4e4e; font-family: inherit; font-size: 10.5pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: PT-BR;">Nova versão do produto contempla todas as features
de BI incluindo a rápida descoberta e exploração de dados com o PowerView e o
BI Semantic Model.<o:p></o:p></span></div>
<h2>
<span style="color: #0071bb;"><span style="font-family: inherit; font-size: 14px;">SQL SERVER 2012 STANDARD</span></span></h2>
<span style="color: #4e4e4e; font-family: inherit; font-size: 10.5pt; line-height: 115%; mso-ansi-language: PT-BR; mso-ascii-theme-font: minor-latin; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: PT-BR; mso-hansi-theme-font: minor-latin;">Funcionalidades
básicas de Database e BI, é indicada apenas para cenários departamentais</span>Everton Limahttp://www.blogger.com/profile/06038304424400850290noreply@blogger.com0tag:blogger.com,1999:blog-2051968848006659883.post-837644160309635962012-11-14T10:27:00.000-02:002012-12-03T11:02:51.826-02:00URL Amigável usando mod_rewrite e PHP (Friendly URL and PHP)<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="post-body entry-content" style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 1.4; position: relative;">
<div style="text-align: justify;">
<span class="Apple-style-span" style="color: red; font-family: Arial, Helvetica, sans-serif; font-size: xx-small;"><b>Tags: URL, amigável, .htaccess, Apache, mod_rewrite, RegEx</b></span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://lh3.googleusercontent.com/-JJLuoKEOdxc/TW-a7TteR5I/AAAAAAAAAJk/2Hfzn8n9Q88/s1600/apache_id_228.png" imageanchor="1" style="clear: left; color: #888888; float: left; margin-bottom: 1em; margin-right: 1em; text-decoration: initial;"><img border="0" height="200" src="https://lh3.googleusercontent.com/-JJLuoKEOdxc/TW-a7TteR5I/AAAAAAAAAJk/2Hfzn8n9Q88/s200/apache_id_228.png" style="-webkit-box-shadow: rgba(0, 0, 0, 0.0980392) 1px 1px 5px; border: 1px solid rgb(238, 238, 238); box-shadow: rgba(0, 0, 0, 0.0980392) 1px 1px 5px; padding: 5px; position: relative;" width="183" /></a></div>
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">Semana passada busquei, estudei e encontrei um maneira legal para trabalhar com URL-amigável, retirar os benditos parametros estranhos (?s=1&m=2) da URL e colocar algo mais amigável para os indexadores de pesquisa e memorização do leitor. O artigo a seguir é para tranformar links assim http://www.site.com.br/processador.php?s=secao&m=materia em links assim http://www.site.com.br/secao/materia.html, "bunitinho" né ;).</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">Primeiro de tudo veja se estar ativo o Módulo mod_rewrite no Apache no httpd.conf, feito isto na raiz do site crie um arquivo .htaccess com um editor de texto tipo notepad e adicione a informação abaixo:</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><IfModule mod_rewrite.c></span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>RewriteEngine On</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>RewriteCond %{REQUEST_FILENAME} !-f</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>RewriteCond %{REQUEST_FILENAME} !-d</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>RewriteCond %{REQUEST_FILENAME} !-l</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>RewriteRule ^([a-zA-Z]*)\/([a-zA-Z]*)\.html$ /unideia/processador.php?s=$1&m=$2 [L,QSA]</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>RewriteCond %{REQUEST_FILENAME} !-f</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>RewriteCond %{REQUEST_FILENAME} !-d</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>RewriteCond %{REQUEST_FILENAME} !-l</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>RewriteRule ^(.*)$ /unideia/processador.php?s=ERRO&u=$1 [L,QSA]</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"></IfModule></span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">Agora comentarei linha a linha as informações do .htaccess</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">-- EXECUTA O QUE ESTIVER DENTRO DO IF SE O MÓDULO FOR ENCONTRADO</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><IfModule mod_rewrite.c></span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>-- ATIVA A REESCRITA PARA ESTA PASTA</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>RewriteEngine On</span></div>
<div style="text-align: justify;">
<span class="Apple-tab-span" style="font-family: Arial, Helvetica, sans-serif; white-space: pre;"> </span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>-- DESATIVA A REESCRITA PARA ARQUIVOS</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>RewriteCond %{REQUEST_FILENAME} !-f</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>-- DESATIVA A REESCRITA PARA PASTAS</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>RewriteCond %{REQUEST_FILENAME} !-d</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>-- DESATIVA A REESCRITAS PARA LINKS</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>RewriteCond %{REQUEST_FILENAME} !-l</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>-- CRIA A REGRA VIA REGEX PARA A ESCRITA, OU SEJA NA URL http://www.site.com.br/secao/materia.html ELE CHAMARA O ARQUIVO PROCESSADOR.PHP PASSANDO COMO PARAMETROS **GET** S=SECAO E M=MATERIA</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>RewriteRule ^([a-zA-Z]*)\/([a-zA-Z]*)\.html$ /processador.php?s=$1&m=$2 [L,QSA]</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>-- AGORA A GRANDE SACADA (POR GENTILEZA, SE ALGUEM TEVE UMA IDÉIA MELHOR SOU TODO OUVIDOS), CASO ALGUEM TENTE FORÇAR ALGO, OU DIGITE UMA URL ERRADA ELE TRATA ISSO TAMBEM</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>-- DESATIVA A REESCRITA PARA ARQUIVOS</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>RewriteCond %{REQUEST_FILENAME} !-f</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>-- DESATIVA A REESCRITA PARA PASTAS</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>RewriteCond %{REQUEST_FILENAME} !-d</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>-- DESATIVA A REESCRITAS PARA LINKS</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>RewriteCond %{REQUEST_FILENAME} !-l</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>-- CRIA A REGRA VIA REGEX PARA A ESCRITA, OU SEJA NA URL http://www.site.com.br/?i=1&s=1 ELE CHAMARA O ARQUIVO PROCESSADOR.PHP PASSANDO COMO PARAMETROS **GET** E=ERRO E U=?i=1&s=1</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><span class="Apple-tab-span" style="white-space: pre;"> </span>RewriteRule ^(.*)$ /processador.php?e=ERRO&u=$1 [L,QSA]</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"></IfModule></span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">Pronto, agora é só criar um arquivo processador.php para tratar os parametros recebidos e chamar os arquivos corretos.</span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: justify;">
<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif;">Espero ter ajudado, qualquer dúvida ou sugestão deixe seu comentário.</span></div>
</div>
</div>
Everton Limahttp://www.blogger.com/profile/06038304424400850290noreply@blogger.com0tag:blogger.com,1999:blog-2051968848006659883.post-1899364698474370332012-11-13T23:46:00.001-02:002012-11-14T10:29:40.668-02:00Pequena coleção de DBCC (A Small Collection of Useful DBCC Commands)<br />
<pre style="background-color: #0b0b0b; border: 0px; color: #bbbbbb; font-family: 'Courier 10 Pitch', Courier, monospace; font-size: 13px; line-height: 1.5; margin-bottom: 1.625em; outline: 0px; overflow: auto; padding: 0.75em 1.625em; vertical-align: baseline;"><span style="border: 0px; color: green; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">-- A Small Collection of Useful DBCC Commands
-- Glenn Berry
-- August 2010
-- http://glennberrysqlperformance.spaces.live.com/
-- Twitter: GlennAlanBerry
-- Clears out contents of buffer cache
-- Use caution before doing this on a production system!
</span><span style="border: 0px; color: blue; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">DBCC </span>DROPCLEANBUFFERS<span style="border: 0px; color: grey; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">;
</span><span style="border: 0px; color: green; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">-- Clears procedure cache on entire<span id="more-153" style="border: 0px; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"></span> SQL instance
</span><span style="border: 0px; color: blue; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">DBCC </span>FREEPROCCACHE<span style="border: 0px; color: grey; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">;
</span><span style="border: 0px; color: green; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">-- Remove the specific plan from the cache using the plan handle
</span><span style="border: 0px; color: blue; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">DBCC </span>FREEPROCCACHE <span style="border: 0px; color: grey; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">(</span>0x060006001ECA270EC0215D05000000000000000000000000<span style="border: 0px; color: grey; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">);
</span><span style="border: 0px; color: green; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">-- Clear ad-hoc SQL plans for entire SQL instance
</span><span style="border: 0px; color: blue; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">DBCC </span>FREESYSTEMCACHE<span style="border: 0px; color: grey; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">(</span><span style="border: 0px; color: red; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">'SQL Plans'</span><span style="border: 0px; color: grey; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">);
</span><span style="border: 0px; color: green; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">-- Clears TokenAndPermUserStore cache on entire SQL instance
</span><span style="border: 0px; color: blue; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">DBCC </span>FREESYSTEMCACHE <span style="border: 0px; color: grey; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">(</span><span style="border: 0px; color: red; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">'TokenAndPermUserStore'</span><span style="border: 0px; color: grey; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">);
</span><span style="border: 0px; color: green; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">-- Releases all unused cache entries from all caches. ALL specifies all supported caches
-- Asynchronously frees currently used entries from their respective caches after they become unused
</span><span style="border: 0px; color: blue; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">DBCC </span>FREESYSTEMCACHE <span style="border: 0px; color: grey; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">(</span><span style="border: 0px; color: red; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">'ALL'</span><span style="border: 0px; color: grey; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">) </span><span style="border: 0px; color: blue; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">WITH MARK_IN_USE_FOR_REMOVAL</span><span style="border: 0px; color: grey; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">;
</span><span style="border: 0px; color: green; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">-- Determine the id of the current database
-- and flush the procedure cache for only that database
</span><span style="border: 0px; color: blue; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">DECLARE </span>@intDBID <span style="border: 0px; color: blue; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">AS INT </span><span style="border: 0px; color: grey; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">= (</span><span style="border: 0px; color: blue; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">SELECT </span><span style="border: 0px; color: magenta; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">DB_ID</span><span style="border: 0px; color: grey; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">());
</span><span style="border: 0px; color: blue; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">DBCC </span>FLUSHPROCINDB <span style="border: 0px; color: grey; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">(</span>@intDBID<span style="border: 0px; color: grey; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">);
</span><span style="border: 0px; color: green; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">-- Clear Wait Stats for entire instance
</span><span style="border: 0px; color: blue; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">DBCC </span>SQLPERF<span style="border: 0px; color: grey; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">(</span><span style="border: 0px; color: red; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">'sys.dm_os_wait_stats'</span><span style="border: 0px; color: grey; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">, </span><span style="border: 0px; color: blue; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">CLEAR</span><span style="border: 0px; color: grey; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">);
</span><span style="border: 0px; color: green; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">-- Get VLF count for transaction log for the current database,
-- number of rows equals VLF count. Lower is better!
</span><span style="border: 0px; color: blue; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">DBCC </span>LOGINFO<span style="border: 0px; color: grey; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">;
</span><span style="border: 0px; color: green; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">-- Returns lots of useful information about memory usage
</span><span style="border: 0px; color: blue; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">DBCC </span>MEMORYSTATUS<span style="border: 0px; color: grey; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">;
</span><span style="border: 0px; color: green; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">-- Find oldest open transaction
</span><span style="border: 0px; color: blue; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">DBCC </span>OPENTRAN<span style="border: 0px; color: grey; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">;
</span><span style="border: 0px; color: green; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">-- Get input buffer for a SPID
</span><span style="border: 0px; color: blue; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">DBCC </span>INPUTBUFFER<span style="border: 0px; color: grey; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">(</span>21<span style="border: 0px; color: grey; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">);
</span><span style="border: 0px; color: green; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">-- Check trace status for instance
</span><span style="border: 0px; color: blue; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">DBCC </span>TRACESTATUS<span style="border: 0px; color: grey; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">(-</span>1<span style="border: 0px; color: grey; font-family: inherit; font-style: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">)</span></pre>
Everton Limahttp://www.blogger.com/profile/06038304424400850290noreply@blogger.com0tag:blogger.com,1999:blog-2051968848006659883.post-33822932643139436192012-11-13T20:00:00.000-02:002012-11-14T10:31:04.333-02:00Usuário órfão no SQL (How to fix orphaned SQL Server users)<br />
<div style="font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 21.600000381469727px; margin: 10px auto; padding: 0px; text-align: justify;">
<span style="background-color: white;">Depois de um bom tempo tentando resolver problemas de usuários órfãos após backups, migração de bancos, log shipping, mirroring e outras ocorrências, pude verificar em diversos blogs e artigos na internet algumas formas de resolver este problema, mas não vi formas de <strong style="margin: 0px; padding: 0px;">evitar</strong> que ele aconteça… O que me deixou impressionado, pois o problema é bem mais simples do que parece (depois que você descobre como funciona, realmente parece simples).</span></div>
<div style="font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 21.600000381469727px; margin: 10px auto; padding: 0px; text-align: justify;">
<span style="background-color: white;">Um exemplo comum de usuário órfão:</span></div>
<div style="font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 21.600000381469727px; margin: 10px auto; padding: 0px; text-align: justify;">
<span style="background-color: white;"><img alt="Usuário Órfão" border="0" height="449" src="http://sqlfromhell.files.wordpress.com/2010/09/image.png?w=500&h=449" style="border: 0px solid rgb(85, 85, 85); display: inline; margin: 0px; padding: 5px;" title="Usuário Órfão" width="500" /></span></div>
<div style="font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 21.600000381469727px; margin: 10px auto; padding: 0px; text-align: justify;">
<strong style="background-color: white; margin: 0px; padding: 0px;">Solução para o problema:</strong></div>
<div style="font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 21.600000381469727px; margin: 10px auto; padding: 0px; text-align: justify;">
<span style="background-color: white;">Para quem chegou a este artigo procurando solucionar um problema de usuários órfãos, você possui várias alternativas:</span></div>
<div style="font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 21.600000381469727px; margin: 10px auto; padding: 0px; text-align: justify;">
<strong style="background-color: white; margin: 0px; padding: 0px;">No SQL Server 2000 e SQL Server 2005:</strong></div>
<div style="font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 21.600000381469727px; margin: 10px auto; padding: 0px; text-align: justify;">
</div>
<div class="syntaxhighlighter " id="highlighter_160578" style="background-image: none !important; border: 1px solid rgb(224, 224, 224) !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 10px auto; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: relative !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 648.4500122070313px;">
<div class="lines" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<div class="line alt1" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background-image: none !important; border-collapse: collapse !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 11px !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;"><span style="background-color: white;">1</span></code></td><td class="content" style="background-image: none !important; border-left-color: rgb(204, 204, 204) !important; border-left-style: solid !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="comments" style="background-color: white; background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">-- Associando a um login existente:</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background-image: none !important; border-collapse: collapse !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 11px !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;"><span style="background-color: white;">2</span></code></td><td class="content" style="background-image: none !important; border-left-color: rgb(204, 204, 204) !important; border-left-style: solid !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: auto !important;"><span style="background-color: white;"><code class="keyword" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">EXEC</code> <code class="plain" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">sp_change_users_login </code><code class="string" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">'Update_One'</code><code class="plain" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">, </code><code class="string" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">'nome do usuário'</code><code class="plain" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">, </code><code class="string" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">'nome do login'</code></span></td></tr>
</tbody></table>
</div>
</div>
</div>
<div style="font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 21.600000381469727px; margin: 10px auto; padding: 0px; text-align: justify;">
</div>
<div style="font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 21.600000381469727px; margin: 10px auto; padding: 0px; text-align: justify;">
<br /></div>
<div style="font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 21.600000381469727px; margin: 10px auto; padding: 0px; text-align: justify;">
</div>
<div class="syntaxhighlighter " id="highlighter_600909" style="background-image: none !important; border: 1px solid rgb(224, 224, 224) !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 10px auto; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: relative !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 648.4500122070313px;">
<div class="lines" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<div class="line alt1" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background-image: none !important; border-collapse: collapse !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 11px !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;"><span style="background-color: white;">1</span></code></td><td class="content" style="background-image: none !important; border-left-color: rgb(204, 204, 204) !important; border-left-style: solid !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="comments" style="background-color: white; background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">--Associando a um login existente com o mesmo nome do usuário,</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background-image: none !important; border-collapse: collapse !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 11px !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;"><span style="background-color: white;">2</span></code></td><td class="content" style="background-image: none !important; border-left-color: rgb(204, 204, 204) !important; border-left-style: solid !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="comments" style="background-color: white; background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">--Ou se não existir login com o mesmo nome do usuário, criar um com a senha informada:</code></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background-image: none !important; border-collapse: collapse !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 11px !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;"><span style="background-color: white;">3</span></code></td><td class="content" style="background-image: none !important; border-left-color: rgb(204, 204, 204) !important; border-left-style: solid !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: auto !important;"><span style="background-color: white;"><code class="keyword" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">EXEC</code> <code class="plain" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">sp_change_users_login </code><code class="string" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">'Auto_Fix'</code><code class="plain" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">, </code><code class="string" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">'nome do usuário'</code><code class="plain" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">, </code><code class="color1" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">NULL</code><code class="plain" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">, </code><code class="string" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">'senha'</code></span></td></tr>
</tbody></table>
</div>
</div>
</div>
<div style="font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 21.600000381469727px; margin: 10px auto; padding: 0px; text-align: justify;">
</div>
<div style="font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 21.600000381469727px; margin: 10px auto; padding: 0px; text-align: justify;">
<span style="background-color: white;">(ref.: <a href="http://msdn.microsoft.com/pt-br/library/ms175475.aspx" style="border-bottom-color: rgb(204, 204, 204); border-bottom-style: dotted; border-bottom-width: 1px; margin: 0px; padding: 0px; text-decoration: initial;">http://msdn.microsoft.com/pt-br/library/ms175475.aspx</a>)</span></div>
<div style="font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 21.600000381469727px; margin: 10px auto; padding: 0px; text-align: justify;">
<strong style="background-color: white; margin: 0px; padding: 0px;">A partir do SQL Server 2005 e SQL Server 2008:</strong></div>
<div style="font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 21.600000381469727px; margin: 10px auto; padding: 0px; text-align: justify;">
</div>
<div class="syntaxhighlighter " id="highlighter_418992" style="background-image: none !important; border: 1px solid rgb(224, 224, 224) !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 10px auto; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: relative !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 648.4500122070313px;">
<div class="lines" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<div class="line alt1" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background-image: none !important; border-collapse: collapse !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 11px !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;"><span style="background-color: white;">1</span></code></td><td class="content" style="background-image: none !important; border-left-color: rgb(204, 204, 204) !important; border-left-style: solid !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="comments" style="background-color: white; background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">-- Associando a um login existente:</code></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background-image: none !important; border-collapse: collapse !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 11px !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;"><span style="background-color: white;">2</span></code></td><td class="content" style="background-image: none !important; border-left-color: rgb(204, 204, 204) !important; border-left-style: solid !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: auto !important;"><span style="background-color: white;"><code class="keyword" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">ALTER</code> <code class="color2" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">USER</code> <code class="plain" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">[nome do usuario] </code><code class="keyword" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">WITH</code> <code class="plain" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">LOGIN = [nome do login]</code></span></td></tr>
</tbody></table>
</div>
</div>
</div>
<div style="font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 21.600000381469727px; margin: 10px auto; padding: 0px; text-align: justify;">
</div>
<div style="font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 21.600000381469727px; margin: 10px auto; padding: 0px; text-align: justify;">
<span style="background-color: white;">(ref.: <a href="http://msdn.microsoft.com/en-us/library/ms176060.aspx" style="border-bottom-color: rgb(204, 204, 204); border-bottom-style: dotted; border-bottom-width: 1px; margin: 0px; padding: 0px; text-decoration: initial;">http://msdn.microsoft.com/en-us/library/ms176060.aspx</a>)</span></div>
<div style="font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 21.600000381469727px; margin: 10px auto; padding: 0px; text-align: justify;">
<strong style="background-color: white; margin: 0px; padding: 0px;">Agora vamos saber por que isso ocorre:</strong></div>
<div style="font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 21.600000381469727px; margin: 10px auto; padding: 0px; text-align: justify;">
<span style="background-color: white;">Os usuários do banco de dados são associados a um código de segurança (SID) dos logins da instância do banco de dados, mas como este SID pode ser aleatório na criação dos logins, o fato de você possuir um login com mesmo nome em duas instâncias do SQL Server distintas, não quer dizer eles são iguais, pois quando o SQL Server tenta restaurar um banco de dados de outra instância, ele só consegue identificar os logins “pais” de seus usuários pelo SID.</span></div>
<div style="font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 21.600000381469727px; margin: 10px auto; padding: 0px; text-align: justify;">
<strong style="background-color: white; margin: 0px; padding: 0px;">Mas se eu forçar um SID para o meu login nas instâncias do SQL Server, será que ainda vou ter o problema? Então vamos conferir:</strong></div>
<div style="font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 21.600000381469727px; margin: 10px auto; padding: 0px; text-align: justify;">
<span style="background-color: white;">Utilizei a seguinte consulta para recuperar o SID de um determinado login:</span></div>
<div style="font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 21.600000381469727px; margin: 10px auto; padding: 0px; text-align: justify;">
</div>
<div class="syntaxhighlighter " id="highlighter_374950" style="background-image: none !important; border: 1px solid rgb(224, 224, 224) !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 10px auto; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: relative !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 648.4500122070313px;">
<div class="lines" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<div class="line alt1" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background-image: none !important; border-collapse: collapse !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 11px !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;"><span style="background-color: white;">1</span></code></td><td class="content" style="background-image: none !important; border-left-color: rgb(204, 204, 204) !important; border-left-style: solid !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: auto !important;"><span style="background-color: white;"><code class="keyword" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">SELECT</code> <code class="keyword" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">name</code><code class="plain" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">, sid </code><code class="keyword" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">FROM</code> <code class="plain" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">sys.server_principals </code><code class="keyword" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">WHERE</code> <code class="plain" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">type = </code><code class="string" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">'S'</code></span></td></tr>
</tbody></table>
</div>
</div>
</div>
<div style="font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 21.600000381469727px; margin: 10px auto; padding: 0px; text-align: justify;">
</div>
<div style="font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 21.600000381469727px; margin: 10px auto; padding: 0px; text-align: justify;">
<span style="background-color: white;"><img alt="SELECT name, sid FROM sys.server_principals WHERE type = 'S'" border="0" height="156" src="http://sqlfromhell.files.wordpress.com/2010/09/image1.png?w=500&h=156" style="border: 0px solid rgb(85, 85, 85); display: inline; margin: 0px; padding: 5px;" title="SELECT name, sid FROM sys.server_principals WHERE type = 'S'" width="500" /></span></div>
<div style="font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 21.600000381469727px; margin: 10px auto; padding: 0px; text-align: justify;">
<span style="background-color: white;">Em outro SQL Server, vou criar um login com mesmo SID:</span></div>
<div style="font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 21.600000381469727px; margin: 10px auto; padding: 0px; text-align: justify;">
</div>
<div class="syntaxhighlighter " id="highlighter_56862" style="background-image: none !important; border: 1px solid rgb(224, 224, 224) !important; bottom: auto !important; direction: ltr !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 11px !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 10px auto; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: relative !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 648.4500122070313px;">
<div class="lines" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<div class="line alt1" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background-image: none !important; border-collapse: collapse !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 11px !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;"><span style="background-color: white;">1</span></code></td><td class="content" style="background-image: none !important; border-left-color: rgb(204, 204, 204) !important; border-left-style: solid !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: auto !important;"><span style="background-color: white;"><code class="keyword" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">CREATE</code> <code class="plain" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">LOGIN paulo</code></span></td></tr>
</tbody></table>
</div>
<div class="line alt2" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background-image: none !important; border-collapse: collapse !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 11px !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;"><span style="background-color: white;">2</span></code></td><td class="content" style="background-image: none !important; border-left-color: rgb(204, 204, 204) !important; border-left-style: solid !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: auto !important;"><span style="background-color: white;"><code class="keyword" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">WITH</code> <code class="keyword" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">PASSWORD</code> <code class="plain" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">= </code><code class="string" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">'p@$$w0rd'</code><code class="plain" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">,</code></span></td></tr>
</tbody></table>
</div>
<div class="line alt1" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<table style="background-image: none !important; border-collapse: collapse !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; font-size: 11px !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><tbody style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">
<tr style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;"><td class="number" style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: 3em !important;"><code style="background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: block !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px 0.3em 0px 0px !important; position: static !important; right: auto !important; text-align: right !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: 2.7em !important;"><span style="background-color: white;">3</span></code></td><td class="content" style="background-image: none !important; border-left-color: rgb(204, 204, 204) !important; border-left-style: solid !important; border-width: 0px 0px 0px 3px !important; bottom: auto !important; direction: ltr !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px 0px 0px 0.5em !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: top !important; width: auto !important;"><code class="plain" style="background-color: white; background-image: none !important; border: 0px !important; bottom: auto !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.3em !important; margin: 0px !important; min-height: auto !important; outline: 0px !important; padding: 0px !important; position: static !important; right: auto !important; text-shadow: none !important; top: auto !important; vertical-align: baseline !important; width: auto !important;">SID = 0x0F5AE6C15103B647A7BD41F744C256F3</code></td></tr>
</tbody></table>
</div>
</div>
</div>
<div style="font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 21.600000381469727px; margin: 10px auto; padding: 0px; text-align: justify;">
</div>
<div style="font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 21.600000381469727px; margin: 10px auto; padding: 0px; text-align: justify;">
<span style="background-color: white;">Após restaurar o banco de dados neste outro servidor, como resultado, sem usuário órfão!</span></div>
<div style="font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 21.600000381469727px; margin: 10px auto; padding: 0px; text-align: justify;">
<span style="background-color: white;"><img alt="Usuário Adotado" border="0" height="449" src="http://sqlfromhell.files.wordpress.com/2010/09/image2.png?w=500&h=449" style="border: 0px solid rgb(85, 85, 85); display: inline; margin: 0px; padding: 5px;" title="Usuário Adotado" width="500" /></span></div>
<div style="font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 21.600000381469727px; margin: 10px auto; padding: 0px; text-align: justify;">
<span style="background-color: white;">E se você tiver um login com nome diferente do login da outra instância, mas com um mesmo SID, o SQL Server ainda utilizará o SID como critério para associar os usuários aos seus respectivos logins, exemplo:</span></div>
<div style="font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 21.600000381469727px; margin: 10px auto; padding: 0px; text-align: justify;">
<span style="background-color: white;"><img alt="Usuário Estranhamente Adotado" border="0" height="449" src="http://sqlfromhell.files.wordpress.com/2010/09/image3.png?w=500&h=449" style="border: 0px solid rgb(85, 85, 85); display: inline; margin: 0px; padding: 5px;" title="Usuário Estranhamente Adotado" width="500" /></span></div>
<div style="font-family: 'Lucida Grande', Verdana, Arial, sans-serif; font-size: 12px; line-height: 21.600000381469727px; margin: 10px auto; padding: 0px; text-align: justify;">
<span style="background-color: white;">Então, criar logins com SIDs iguais entre instâncias do SQL Server, evitará que problemas de usuários órfãos ocorram novamente, seja por backups, migração de bancos, log shipping e mirroring! A partir de agora, só diversão!</span></div>
Everton Limahttp://www.blogger.com/profile/06038304424400850290noreply@blogger.com0tag:blogger.com,1999:blog-2051968848006659883.post-43857664117817061042007-05-29T23:00:00.001-03:002012-11-13T20:02:31.881-02:00Estreando!<div xmlns="http://www.w3.org/1999/xhtml">
Bom.. Aproveitando da tecnologia da Adobe e usando o Contribute CS3, postamos o nosso primeiro texto no Blogger.com. <br />
Vamos passar muita novidades da área.<br />
Enjoy! <br /> </div>
Everton Limahttp://www.blogger.com/profile/06038304424400850290noreply@blogger.com0