<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-436940714252520724</id><updated>2024-09-01T10:50:18.002-06:00</updated><title type='text'>Instrucciones rápidas en T-SQL</title><subtitle type='html'>Es una recopilación de funciones rápidas para Microsoft Transact SQL</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://instruccionsql.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://instruccionsql.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Edd</name><uri>http://www.blogger.com/profile/09985292416186758161</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>96</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-436940714252520724.post-1204429680120920101</id><published>2011-10-06T08:00:00.000-05:00</published><updated>2011-10-06T08:00:09.875-05:00</updated><title type='text'>Conocer la estructura de una tabla</title><content type='html'>&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;EXEC sp_MShelpcolumns &#39;Avales&#39;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://instruccionsql.blogspot.com/feeds/1204429680120920101/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/conocer-la-estructura-de-una-tabla.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/1204429680120920101'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/1204429680120920101'/><link rel='alternate' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/conocer-la-estructura-de-una-tabla.html' title='Conocer la estructura de una tabla'/><author><name>Edd</name><uri>http://www.blogger.com/profile/09985292416186758161</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-436940714252520724.post-5055257416429636232</id><published>2011-10-05T10:42:00.001-05:00</published><updated>2011-10-05T10:47:33.274-05:00</updated><title type='text'>Convierte un número a letra</title><content type='html'>&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;/************************************************&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt; Convierte un número a letra&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt; execute sp_ConvertNumberToLetter 91234.78, &#39;&#39;,0,1&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt; Ej: 3456 &amp;gt; Tres Mil Cuatrociectos Cincuenta y Seis&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;*************************************************/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;CREATE PROCEDURE sp_ConvertNumberToLetter&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; @iNumber VARCHAR(20),&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; @sResult VARCHAR(2000) OUTPUT,&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; @bUpperCase BIT = 1,&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; @bForProvider BIT = 0&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;AS&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; DECLARE @sNumber AS VARCHAR(13)&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; DECLARE @iLenght AS TINYINT&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; DECLARE @iCounter AS TINYINT&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; DECLARE @iQuota AS TINYINT&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; DECLARE @sPlus AS VARCHAR(20)&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; DECLARE @iPosition AS TINYINT&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; DECLARE @sHundreds AS NVARCHAR(3)&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; DECLARE @sHundOfThou AS NVARCHAR(3)&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; DECLARE @sHundOfMill AS NVARCHAR(3)&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; DECLARE @sHundOfTril AS NVARCHAR(3)&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; DECLARE @sDecimal AS VARCHAR(2)&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; DECLARE @sResults1 AS VARCHAR(200)&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; DECLARE @sResults2 AS VARCHAR(200)&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; DECLARE @sResults3 AS VARCHAR(200)&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; DECLARE @sResults4 AS VARCHAR(200)&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; DECLARE @sSubNumber AS VARCHAR(25)&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; --Convierte el número en NVarchar&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; SELECT @sNumber = RTRIM(CAST(@iNumber AS VARCHAR(13)))&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; --Quita los espacios en Blanco&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; SET @sNumber = RTRIM ( LTRIM( @sNumber ) )&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; --Inicia el contador en 1&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; SET @iCounter = 1&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; /*Separa la cantidad correspondiente a los centavos (SI EXISTEN)*/&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;-- SELECT CHARINDEX( &#39;.&#39;, @sNumber )&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; IF CHARINDEX( &#39;.&#39;, @sNumber ) &amp;lt;&amp;gt; 0&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; BEGIN&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; --Busca el lugar donde se encuentre el punto decimal y a partir del siguiente caracter&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; --lo convierte en la parte decimal del número&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @sDecimal = SUBSTRING( @sNumber, CHARINDEX( &#39;.&#39;, @sNumber ) + 1 , LEN( @sNumber ) )&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;--&amp;nbsp;&amp;nbsp;&amp;nbsp; select @sdecimal, &#39;@sdecimal&#39;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; --Desaparece esa parte decimal del número en general&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF RTRIM(@sDecimal) &amp;lt;&amp;gt; &#39;&#39;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BEGIN&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @sNumber = SUBSTRING( @sNumber, 1, CHARINDEX( &#39;.&#39;, @sNumber ) - 1 )&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;--&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select @snumber, &#39;@snumber&#39;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; END&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; END&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; /*SI NO EXISTEN LOS PONE COMO 00/100*/&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; ELSE&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; BEGIN&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @sDecimal = &#39;00&#39;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; END&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; --Invierte la cadena para obtener los números reales a convertir&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; SET @sNumber = REVERSE(@sNumber)&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;-- SELECT @sNumber&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; --Obtiene su longitud&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; SET @iLenght = LEN(@sNumber)&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; --Los separa en cantidades de 3 numeros&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; WHILE ( @iLenght &amp;gt; 0) AND ( @iCounter &amp;lt;= 4 )&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; BEGIN&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;--&amp;nbsp;&amp;nbsp; SELECT @sNumber , &#39;aqui toy&#39;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /*Verifica que haya mas de 3 numeros en la cadena*/&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF @iLenght &amp;gt;= 3&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BEGIN&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @iQuota = 3&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; END&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ELSE&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BEGIN&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @iQuota = @iLenght&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; END&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /*Guarda en cada variable la cadena de números repartida*/&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF @iCounter = 1&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BEGIN&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @sHundreds = SUBSTRING( @sNumber, 1 , @iQuota )&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @sHundreds = REVERSE( @sHundreds&amp;nbsp; )&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; END&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF @iCounter = 2&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BEGIN&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @sHundOfThou&amp;nbsp;&amp;nbsp; = SUBSTRING( @sNumber, 1 , @iQuota )&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @sHundOfThou&amp;nbsp; = REVERSE( @sHundOfThou )&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; END&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF @iCounter = 3&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BEGIN&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @sHundOfMill = SUBSTRING( @sNumber, 1 , @iQuota )&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @sHundOfMill = REVERSE( @sHundOfMill )&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; END&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF @iCounter = 4&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BEGIN&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @sHundOfTril = SUBSTRING( @sNumber, 1 , @iQuota )&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @sHundOfTril = REVERSE( @sHundOfTril )&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; END&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @sNumber = SUBSTRING(@sNumber , @iQuota + 1 , @ilenght )&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @iCounter = @iCounter + 1&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; --Obtiene su longitud&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @iLenght = LEN(@sNumber)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; END&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; /*Incializa las variables de resultados*/&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @sResults1 = &#39;&#39;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set @sResults2 = &#39;&#39;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set @sResults3 = &#39;&#39;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set @sResults4 = &#39;&#39;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;-- EXECUTE sp_ConvertHundredsOfThousands @sHundOfThou , @sResults2 OUTPUT&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; /*Unidades a Centenas*/&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; EXECUTE sp_ConvertHundreds @sHundreds, @sResults1 OUTPUT&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; /*Unidades de Millar a Centenas de Millar&amp;nbsp; */&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; EXECUTE sp_ConvertHundredsOfThousands @sHundOfThou , @sResults2 OUTPUT&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; /*Unidades de Millon as Centenas de Millon*/&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; EXECUTE sp_ConvertHundredsOfMillion @sHundOfMill , @sResults3 OUTPUT&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; /*Unidades de Billon a Centenas de Billon*/&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; EXECUTE sp_ConvertHundredsOfThousands @sHundOfTril , @sResults4 OUTPUT&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; /************************************************************&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; Se evalúan las terminaciones que se agregarán para el caso de los Miles de Millones&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; *****************************************************************/&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; IF ( RTRIM( @sResults3 ) = &#39;&#39; )&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; AND ( RTRIM( @sResults4 ) &amp;lt;&amp;gt; &#39;&#39; )&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; AND ( RTRIM( @sResults1 ) = &#39;&#39; )&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; BEGIN&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @sPlus = &#39;Millones&#39;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; END&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; ELSE&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; BEGIN&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @sPlus = &#39;&#39;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; END&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; /*Se concatena el resultado*/&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; SET @sResult =&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; LTRIM( RTRIM( @sResults4 ) ) + &#39; &#39; + @sPlus +&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; LTRIM( RTRIM( @sResults3 ) ) + &#39; &#39; &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;+&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; LTRIM( RTRIM( @sResults2 ) ) + &#39; &#39; +&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; LTRIM( RTRIM( @sResults1 ) )&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; /*Agrega la palabra &#39;Pesos&#39; y los centavos*/&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; SET @sResult = @sResult + &#39; Pesos&#39; + &#39; &#39; +&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; LTRIM( RTRIM( @sDecimal ) ) + &#39;/100 M.N.&#39;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; /*Verifica si es que existe alguna cantidad&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; antes de la palabra pesos, de no ser asi&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pone CERO*/&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; IF CHARINDEX( &#39;P&#39;, LTRIM( @sResult ) ) = 1&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; BEGIN&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @sResult = &#39;Cero &#39; + LTRIM( @sResult )&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; END&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; /*Verifica que se escriba &quot;UN PESO&quot; y no &quot;UN PESOS&quot;*/&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; IF ( CHARINDEX( &#39;UN&#39;, LTRIM( @sResult ) ) = 1 )&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AND ( CHARINDEX( &#39;P&#39;, LTRIM( @sResult ) ) = 4 )&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; BEGIN&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @sResult = REPLACE( @sResult, &#39;Pesos&#39;, &#39;Peso&#39; )&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; END&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; /*Verifica que se introduzca la palabra &quot;DE&quot; en el caso de los millones cerrados (Cuando el Modulo es 0 se introduce)*/&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; /*Obtiene el número dividido entre 1 millón*/&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; SET @sSubNumber = CAST( CAST( @iNumber AS DECIMAL ) / 1000000&amp;nbsp; AS VARCHAR(25) )&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; /*Separa la cadena después del punto*/&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; SET @sSubNumber = SUBSTRING( @sSubNumber , CHARINDEX( &#39;.&#39;, @sSubNumber ) + 1 , LEN( @sSubNumber ) )&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; /*Comprueba después que la cadena separada sea mayor a 0 para poner la palabra &quot;DE&quot;*/&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; IF CAST( @sSubNumber AS INTEGER ) = 0&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; BEGIN&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @sResult = REPLACE ( @sResult, &#39;Pesos&#39;,&amp;nbsp; &#39;de pesos&#39;)&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @sResult = REPLACE ( @sResult, &#39;&amp;nbsp; de&#39;, &#39;de&#39;)&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; END&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; /*Para la posteridad, reemplaza donde halla &#39;&amp;nbsp; pesos&#39;*/&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; SET @sResult = REPLACE( @sResult, &#39;&amp;nbsp; peso&#39;, &#39; peso&#39; )&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; SET @sResult = LTRIM( RTRIM( @sResult&amp;nbsp; ) )&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; /*¿Se convierten a mayúsculas?*/&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; IF @bUpperCase = 1&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; BEGIN&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @sResult = LTRIM( RTRIM(UPPER( @sResult ) ) )&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; END&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; /*¿Es una respuesta para el proveedor*/&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp; IF @bForProvider = 1&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; BEGIN&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SELECT @sResult&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; END&lt;/span&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://instruccionsql.blogspot.com/feeds/5055257416429636232/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/convierte-un-numero-letra.html#comment-form' title='2 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/5055257416429636232'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/5055257416429636232'/><link rel='alternate' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/convierte-un-numero-letra.html' title='Convierte un número a letra'/><author><name>Edd</name><uri>http://www.blogger.com/profile/09985292416186758161</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-436940714252520724.post-2521722848354012875</id><published>2011-10-05T10:31:00.001-05:00</published><updated>2011-10-05T10:32:03.719-05:00</updated><title type='text'>Crear tabla de Amortización (método francés)</title><content type='html'>&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #454545; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;/***********************************************************************************************&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Objetivo: Crear tabla de amortizacion método francés&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Fecha: 20/Julio/2011&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;exec sp_AmortizacionFrances 25000,12,0.85&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;************************************************************************************************/&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Alter Procedure sp_AmortizacionFrances&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;yiv1209780160Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;@Prestamo float&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;yiv1209780160Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;,@Periodos smallint&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;yiv1209780160Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;,@Tasa float&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;As&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;-- 0. Declara variables&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Declare @TasaMens float&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Declare @TasaT1 float&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Declare @CuotaC1 float&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Declare @CuotaC1mT1 float&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Declare @Amortizacion float&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Declare @UltAmortizado float&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Declare @TotAmortizado float&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Declare @Cuota float&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Declare @Total float&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Declare @Interes float&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Declare @Contador smallint&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;-- 1. Crear tabla amortización&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;If object_id(&#39;tempdb..#Amortizacion&#39;) is not null drop table #Amortizacion&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Create table #Amortizacion (&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;yiv1209780160Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;Mes smallint&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;yiv1209780160Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;,Total float&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;yiv1209780160Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;,Interes float&lt;span class=&quot;yiv1209780160Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;yiv1209780160Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;,Cuota float&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;yiv1209780160Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;,Amortizacion float&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;yiv1209780160Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;,Amortizado float&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;yiv1209780160Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;-- 2. Asignacion valores&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;-- Set @Prestamo=500&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;-- Set @Periodos=5&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;-- Set @Tasa=0.10&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Set @TasaMens=@Tasa/12&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Set @TasaT1=@Prestamo*@TasaMens&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Set @CuotaC1=@Prestamo*((power(1+@TasaMens,@Periodos)*@TasaMens)/(power(1+@TasaMens,@Periodos)-1))&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Set @CuotaC1mT1=@CuotaC1-@TasaT1&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;-- 3. Calcula primera Amortizacion&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Insert into #Amortizacion values(1,@Prestamo,@TasaT1,@CuotaC1,@CuotaC1-@TasaT1,@CuotaC1-@TasaT1)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;-- 4. Calculo antes ciclo&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Set @Amortizacion=@CuotaC1-@TasaT1&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Set @UltAmortizado=@CuotaC1-@TasaT1&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Set @Total=@Prestamo-@Amortizacion&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Set @Contador=2&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;While @Contador &amp;lt;= @Periodos&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Begin&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;yiv1209780160Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;yiv1209780160Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;Set @Interes=(@Prestamo-@CuotaC1mT1*(power(1+@TasaMens,@Contador-1)-1)/@TasaMens)*@TasaMens&lt;span class=&quot;yiv1209780160Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;yiv1209780160Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;Set @Cuota=@Prestamo*((power(1+@TasaMens,@Periodos)*@TasaMens)/(power(1+@TasaMens,@Periodos)-1))&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;yiv1209780160Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;Set @Amortizacion=@Cuota-@Interes&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;yiv1209780160Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;Set @TotAmortizado=@Amortizacion+@UltAmortizado&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;yiv1209780160Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;yiv1209780160Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;--Amortizacion n&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;yiv1209780160Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;Insert into #Amortizacion values&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;yiv1209780160Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;(@Contador,@Total,@Interes,@Cuota,@Amortizacion,@TotAmortizado)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;yiv1209780160Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;yiv1209780160Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;Set @UltAmortizado=@Amortizacion+@UltAmortizado&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;yiv1209780160Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;Set @Total=@Total-@Amortizacion&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Set @Contador=@Contador+1&lt;span class=&quot;yiv1209780160Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;End&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div id=&quot;yui_3_2_0_1_1317828533599103&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;--5. Resultado&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;Select * from #Amortizacion&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;compute sum(interes),sum(Amortizacion),sum(cuota)&lt;/span&gt;&lt;/div&gt;
&lt;br class=&quot;Apple-interchange-newline&quot; /&gt;</content><link rel='replies' type='application/atom+xml' href='http://instruccionsql.blogspot.com/feeds/2521722848354012875/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/objetivo-crear-tabla-de-amortizacion.html#comment-form' title='8 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/2521722848354012875'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/2521722848354012875'/><link rel='alternate' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/objetivo-crear-tabla-de-amortizacion.html' title='Crear tabla de Amortización (método francés)'/><author><name>Edd</name><uri>http://www.blogger.com/profile/09985292416186758161</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-436940714252520724.post-2510298978480255010</id><published>2011-10-05T09:52:00.001-05:00</published><updated>2011-10-05T09:52:15.183-05:00</updated><title type='text'>Buscar texto en todos los SPs</title><content type='html'>&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;CREATE proc dbo.p_FindText&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;@strFind varchar (100),&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;@varDBName varchar (100) = &#39;MIBASE&#39;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;AS&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;BEGIN&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Declare @varQuery varchar (1000)&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;select @varQuery =&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&#39;SELECT distinct &#39; +&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&#39;name SP_Name, &#39;&#39;sp_helptext &#39;&#39;&#39;&#39;&#39;&#39; + name + &#39;&#39;&#39;&#39;&#39;&#39;&#39;&#39;SP_HT &#39; +&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&#39;FROM [&#39; + @varDBName + &#39;].[dbo].[sysobjects] &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;inner join [&#39; + @varDBName + &#39;].[dbo].[syscomments] &#39; +&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&#39;on [&#39; + @varDBName + &#39;].[dbo].[sysobjects].id &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;= [&#39; + @varDBName + &#39;].[dbo].[syscomments].id &#39; +&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&#39;where xtype = &#39;&#39;P&#39;&#39; &#39; +&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&#39;and text like &#39;&#39;%&#39; + @strFind + &#39;%&#39;&#39; &#39; +&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&#39;order by name &#39;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;exec (@varQuery)&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;END --sp&lt;/span&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://instruccionsql.blogspot.com/feeds/2510298978480255010/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/buscar-texto-en-todos-los-sps.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/2510298978480255010'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/2510298978480255010'/><link rel='alternate' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/buscar-texto-en-todos-los-sps.html' title='Buscar texto en todos los SPs'/><author><name>Edd</name><uri>http://www.blogger.com/profile/09985292416186758161</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-436940714252520724.post-564040523420641167</id><published>2011-10-05T09:51:00.001-05:00</published><updated>2011-10-05T09:51:32.703-05:00</updated><title type='text'>Encontrar duplicados</title><content type='html'>&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;SELECT email,COUNT(email) AS NumOccurrences&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;FROM users&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;GROUP BY email&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;HAVING ( COUNT(email) &amp;gt; 1 )&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://instruccionsql.blogspot.com/feeds/564040523420641167/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/encontrar-duplicados.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/564040523420641167'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/564040523420641167'/><link rel='alternate' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/encontrar-duplicados.html' title='Encontrar duplicados'/><author><name>Edd</name><uri>http://www.blogger.com/profile/09985292416186758161</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-436940714252520724.post-790811668572545594</id><published>2011-10-05T09:50:00.001-05:00</published><updated>2011-10-05T09:50:51.259-05:00</updated><title type='text'>Trasponer una tabla</title><content type='html'>&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;If object_id(&#39;tmpTabla1&#39;) is not null drop table tmpTabla1&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Create table tmpTabla1 (Numero int,Tipo varchar(3),Importe float)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Insert into tmpTabla1 values (1990,&#39;CAP&#39;,100)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Insert into tmpTabla1 values (1990,&#39;INT&#39;,20)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Insert into tmpTabla1 values (1990,&#39;IVA&#39;,1)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Insert into tmpTabla1 values (1995,&#39;CAP&#39;,300)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Insert into tmpTabla1 values (1995,&#39;INT&#39;,200)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Insert into tmpTabla1 values (1995,&#39;IVA&#39;,100)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Insert into tmpTabla1 values (2000,&#39;CAP&#39;,100)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Insert into tmpTabla1 values (2000,&#39;INT&#39;,20)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Insert into tmpTabla1 values (2000,&#39;IVA&#39;,1)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Insert into tmpTabla1 values (2005,&#39;CAP&#39;,300)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Insert into tmpTabla1 values (2005,&#39;INT&#39;,200)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Insert into tmpTabla1 values (2005,&#39;IVA&#39;,100)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;--Truncate table tmpTabla1&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Select * from tmpTabla1&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;SELECT Numero,&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Cap= ISNULL((SELECT Importe FROM tmpTabla1 WHERE Tipo = &#39;CAP&#39; and Numero=t.Numero),0),&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [Int]= ISNULL((SELECT Importe FROM tmpTabla1 WHERE Tipo = &#39;INT&#39; and Numero=t.Numero),0),&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Iva= ISNULL((SELECT Importe FROM tmpTabla1 WHERE Tipo = &#39;IVA&#39; and Numero=t.Numero),0)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;FROM tmpTabla1 t&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;GROUP BY Numero&lt;/span&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://instruccionsql.blogspot.com/feeds/790811668572545594/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/trasponer-una-tabla.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/790811668572545594'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/790811668572545594'/><link rel='alternate' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/trasponer-una-tabla.html' title='Trasponer una tabla'/><author><name>Edd</name><uri>http://www.blogger.com/profile/09985292416186758161</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-436940714252520724.post-7403577141154340154</id><published>2011-10-05T09:49:00.003-05:00</published><updated>2011-10-05T09:49:58.783-05:00</updated><title type='text'>Elimina registros duplicados en una tabla</title><content type='html'>&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Drop table tmpT1&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Create table tmpT1 (col1 int,col2 int)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Insert into tmpT1 values (1,1)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Insert into tmpT1 values (1,2)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Insert into tmpT1 values (1,1) --duplicada&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Insert into tmpT1 values (1,4)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Insert into tmpT1 values (1,5)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;drop table tmpT2&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Select * into tmpT2 from tmpT1&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;truncate table tmpT2&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Declare @Col1 int,@Col2 int&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Declare CursorA CURSOR forward_only FOR&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Select * from tmpT1&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;OPEN CursorA&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;FETCH NEXT FROM CursorA &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;INTO @Col1,@Col2&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;WHILE @@FETCH_STATUS = 0&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;BEGIN&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; If not exists(Select * from tmpT2 where Col1=@Col1 and Col2=@Col2)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Insert into tmpt2 values (@Col1,@Col2)&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FETCH NEXT FROM CursorA &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INTO @Col1,@Col2&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;END&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;CLOSE CursorA&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;DEALLOCATE CursorA&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Select * from tmpT1&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Select * from tmpT2&lt;/span&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://instruccionsql.blogspot.com/feeds/7403577141154340154/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/elimina-registros-duplicados-en-una.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/7403577141154340154'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/7403577141154340154'/><link rel='alternate' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/elimina-registros-duplicados-en-una.html' title='Elimina registros duplicados en una tabla'/><author><name>Edd</name><uri>http://www.blogger.com/profile/09985292416186758161</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-436940714252520724.post-4374996884086296549</id><published>2011-10-05T09:49:00.001-05:00</published><updated>2011-10-05T09:49:05.300-05:00</updated><title type='text'>Función DIFFERENCE</title><content type='html'>&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;SELECT DIFFERENCE(&#39;Smithers&#39;, &#39;Smythers&#39;)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;SELECT DIFFERENCE(&#39;Anothers&#39;, &#39;Brothers&#39;)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;SELECT DIFFERENCE(&#39;Perez&#39;, &#39;WSAeMilaAerezaZXCS&#39;)&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://instruccionsql.blogspot.com/feeds/4374996884086296549/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/funcion-difference.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/4374996884086296549'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/4374996884086296549'/><link rel='alternate' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/funcion-difference.html' title='Función DIFFERENCE'/><author><name>Edd</name><uri>http://www.blogger.com/profile/09985292416186758161</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-436940714252520724.post-8513510656318362065</id><published>2011-10-05T09:48:00.003-05:00</published><updated>2011-10-05T09:48:39.788-05:00</updated><title type='text'>Función SOUNDEX</title><content type='html'>&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;SELECT SOUNDEX (&#39;Smith&#39;), SOUNDEX (&#39;Smitheres&#39;)&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://instruccionsql.blogspot.com/feeds/8513510656318362065/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/funcion-soundex.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/8513510656318362065'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/8513510656318362065'/><link rel='alternate' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/funcion-soundex.html' title='Función SOUNDEX'/><author><name>Edd</name><uri>http://www.blogger.com/profile/09985292416186758161</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-436940714252520724.post-3470485581463229283</id><published>2011-10-05T09:48:00.001-05:00</published><updated>2011-10-05T09:48:08.545-05:00</updated><title type='text'>Función SPLIT</title><content type='html'>&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-size: small;&quot;&gt;CREATE FUNCTION dbo.Split(@String varchar(8000), @Delimiter char(1))&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;returns @temptable TABLE (items varchar(8000))&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;as&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;begin&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; declare @idx int&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; declare @slice varchar(8000)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select @idx = 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(@String)&amp;lt;1 or @String is null&amp;nbsp; return&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while @idx!= 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; begin&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set @idx = charindex(@Delimiter,@String)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if @idx!=0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set @slice = left(@String,@idx - 1)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set @slice = @String&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(len(@slice)&amp;gt;0)&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; insert into @temptable(Items) values(@slice)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set @String = right(@String,len(@String) - @idx)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(@String) = 0 break&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end&amp;nbsp;&amp;nbsp; &lt;br /&gt;return&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;end&amp;nbsp; &lt;br /&gt;Select top 10 * from dbo.split(&#39;Chennai,Bangalore,Mumbai&#39;,&#39;,&#39;)&amp;nbsp; &lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://instruccionsql.blogspot.com/feeds/3470485581463229283/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/funcion-split.html#comment-form' title='1 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/3470485581463229283'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/3470485581463229283'/><link rel='alternate' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/funcion-split.html' title='Función SPLIT'/><author><name>Edd</name><uri>http://www.blogger.com/profile/09985292416186758161</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-436940714252520724.post-3501966747426786494</id><published>2011-10-05T09:47:00.001-05:00</published><updated>2011-10-05T09:47:30.269-05:00</updated><title type='text'>Obtener fecha sin la hora (otra versión)</title><content type='html'>&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-size: small;&quot;&gt;SELECT CAST(CONVERT(VARCHAR(10), getdate(), 111) AS DATETIME)&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://instruccionsql.blogspot.com/feeds/3501966747426786494/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/obtener-fecha-sin-la-hora-otra-version.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/3501966747426786494'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/3501966747426786494'/><link rel='alternate' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/obtener-fecha-sin-la-hora-otra-version.html' title='Obtener fecha sin la hora (otra versión)'/><author><name>Edd</name><uri>http://www.blogger.com/profile/09985292416186758161</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-436940714252520724.post-3246579926307726560</id><published>2011-10-05T09:46:00.001-05:00</published><updated>2011-10-05T09:46:46.381-05:00</updated><title type='text'>Obtener la fecha sin la hora</title><content type='html'>&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;SELECT CAST(CAST(YEAR(getdate()) AS VARCHAR(4)) + &#39;/&#39; +&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CAST(MONTH(getdate()) AS VARCHAR(2)) + &#39;/&#39; +&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CAST(DAY(getdate()) AS VARCHAR(2)) AS DATETIME)&lt;/span&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://instruccionsql.blogspot.com/feeds/3246579926307726560/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/obtener-la-fecha-sin-la-hora.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/3246579926307726560'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/3246579926307726560'/><link rel='alternate' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/obtener-la-fecha-sin-la-hora.html' title='Obtener la fecha sin la hora'/><author><name>Edd</name><uri>http://www.blogger.com/profile/09985292416186758161</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-436940714252520724.post-8559793506003264740</id><published>2011-10-05T09:45:00.001-05:00</published><updated>2011-10-05T09:45:55.812-05:00</updated><title type='text'>Ejecutar un script desde la linea de comandos</title><content type='html'>&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;osql -Sntserverx -Usa -Pmypassword -dBASE20111005 -i &quot;E:\File\scripts\Script1.sql&quot;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://instruccionsql.blogspot.com/feeds/8559793506003264740/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/ejecutar-un-script-desde-la-linea-de.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/8559793506003264740'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/8559793506003264740'/><link rel='alternate' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/ejecutar-un-script-desde-la-linea-de.html' title='Ejecutar un script desde la linea de comandos'/><author><name>Edd</name><uri>http://www.blogger.com/profile/09985292416186758161</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-436940714252520724.post-4362955959328415363</id><published>2011-10-05T09:44:00.003-05:00</published><updated>2011-10-05T09:44:36.222-05:00</updated><title type='text'>Dividir un nombre en más de dos partes</title><content type='html'>&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;DECLARE @FullName VARCHAR(100)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;SET @FullName = &#39;John Doe Lopez&#39;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;SELECT PARSENAME(REPLACE(@FullName, &#39; &#39;, &#39;.&#39;), 3) AS [Last2Name],&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PARSENAME(REPLACE(@FullName, &#39; &#39;, &#39;.&#39;), 2) AS [FirstName],&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PARSENAME(REPLACE(@FullName, &#39; &#39;, &#39;.&#39;), 1) AS [LastName]&lt;/span&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://instruccionsql.blogspot.com/feeds/4362955959328415363/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/dividir-un-nombre-en-mas-de-dos-partes.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/4362955959328415363'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/4362955959328415363'/><link rel='alternate' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/dividir-un-nombre-en-mas-de-dos-partes.html' title='Dividir un nombre en más de dos partes'/><author><name>Edd</name><uri>http://www.blogger.com/profile/09985292416186758161</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-436940714252520724.post-2797670375434619851</id><published>2011-10-05T09:44:00.001-05:00</published><updated>2011-10-05T09:44:00.783-05:00</updated><title type='text'>Dividir nombre completo en apellidos</title><content type='html'>&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;DECLARE @FullName VARCHAR(100)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;SET @FullName = &#39;Juan Perez&#39;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;SELECT SUBSTRING(@FullName, 1, CHARINDEX(&#39; &#39;, @FullName) - 1) AS [FirstName],&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;SUBSTRING(@FullName, CHARINDEX(&#39; &#39;, @FullName) + 1, LEN(@FullName)) AS [LastName]&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://instruccionsql.blogspot.com/feeds/2797670375434619851/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/dividir-nombre-completo-en-apellidos.html#comment-form' title='2 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/2797670375434619851'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/2797670375434619851'/><link rel='alternate' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/dividir-nombre-completo-en-apellidos.html' title='Dividir nombre completo en apellidos'/><author><name>Edd</name><uri>http://www.blogger.com/profile/09985292416186758161</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-436940714252520724.post-3734316507979431778</id><published>2011-10-05T09:43:00.001-05:00</published><updated>2011-10-05T09:43:09.709-05:00</updated><title type='text'>Generar un número al azar</title><content type='html'>&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;SELECT ABS(CAST(CAST(NEWID() AS VARBINARY) AS INT)) AS [RandomNumber],Contrato,Grupo,Integrante&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;From Contratos where contrato &amp;gt; 400000&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://instruccionsql.blogspot.com/feeds/3734316507979431778/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/generar-un-numero-al-azar.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/3734316507979431778'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/3734316507979431778'/><link rel='alternate' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/generar-un-numero-al-azar.html' title='Generar un número al azar'/><author><name>Edd</name><uri>http://www.blogger.com/profile/09985292416186758161</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-436940714252520724.post-1246157736015675903</id><published>2011-10-05T09:42:00.003-05:00</published><updated>2011-10-05T09:42:38.104-05:00</updated><title type='text'>Controlar el error División entre cero</title><content type='html'>&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;SELECT ISNULL([Numerator] / NULLIF([Denominator], 0), 0) AS [Percentage] FROM [Table1]&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;SELECT CASE WHEN [Denominator] = 0 THEN 0 ELSE [Numerator] / [Denominator] END AS [Percentage]&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;FROM [Table1]&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://instruccionsql.blogspot.com/feeds/1246157736015675903/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/controlar-el-error-division-entre-cero.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/1246157736015675903'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/1246157736015675903'/><link rel='alternate' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/controlar-el-error-division-entre-cero.html' title='Controlar el error División entre cero'/><author><name>Edd</name><uri>http://www.blogger.com/profile/09985292416186758161</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-436940714252520724.post-7271361584566841134</id><published>2011-10-05T09:42:00.001-05:00</published><updated>2011-10-05T09:42:03.099-05:00</updated><title type='text'>Modifica la columna de una tabla</title><content type='html'>&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;ALTER TABLE [dbo].[Customers] ALTER COLUMN [CustomerID] INT NOT NULL&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://instruccionsql.blogspot.com/feeds/7271361584566841134/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/modifica-la-columna-de-una-tabla.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/7271361584566841134'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/7271361584566841134'/><link rel='alternate' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/modifica-la-columna-de-una-tabla.html' title='Modifica la columna de una tabla'/><author><name>Edd</name><uri>http://www.blogger.com/profile/09985292416186758161</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-436940714252520724.post-915182557638506083</id><published>2011-10-05T09:41:00.001-05:00</published><updated>2011-10-05T09:41:24.795-05:00</updated><title type='text'>Cambiar el tamaño de la columna</title><content type='html'>&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;ALTER TABLE [dbo].[Customers] ALTER COLUMN [FirstName] VARCHAR(50)&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://instruccionsql.blogspot.com/feeds/915182557638506083/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/cambiar-el-tamano-de-la-columna.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/915182557638506083'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/915182557638506083'/><link rel='alternate' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/cambiar-el-tamano-de-la-columna.html' title='Cambiar el tamaño de la columna'/><author><name>Edd</name><uri>http://www.blogger.com/profile/09985292416186758161</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-436940714252520724.post-6033319164457265519</id><published>2011-10-05T09:40:00.001-05:00</published><updated>2011-10-05T09:40:44.766-05:00</updated><title type='text'>Conocer si una tabla tiene llave primaria</title><content type='html'>&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;IF OBJECTPROPERTY( OBJECT_ID( &#39;[dbo].[Customers]&#39; ), &#39;TableHasPrimaryKey&#39; ) = 1&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; PRINT &#39;[dbo].[Customers] table has a primary key.&#39;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://instruccionsql.blogspot.com/feeds/6033319164457265519/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/conocer-si-una-tabla-tiene-llave.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/6033319164457265519'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/6033319164457265519'/><link rel='alternate' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/conocer-si-una-tabla-tiene-llave.html' title='Conocer si una tabla tiene llave primaria'/><author><name>Edd</name><uri>http://www.blogger.com/profile/09985292416186758161</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-436940714252520724.post-265733112869948123</id><published>2011-10-05T09:39:00.003-05:00</published><updated>2011-10-05T09:39:56.066-05:00</updated><title type='text'>Cambiar el propietario de una tabla</title><content type='html'>&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;EXECUTE sp_changeobjectowner &#39;dbo.Customers&#39;, &#39;my&#39;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://instruccionsql.blogspot.com/feeds/265733112869948123/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/cambiar-el-propietario-de-una-tabla.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/265733112869948123'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/265733112869948123'/><link rel='alternate' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/cambiar-el-propietario-de-una-tabla.html' title='Cambiar el propietario de una tabla'/><author><name>Edd</name><uri>http://www.blogger.com/profile/09985292416186758161</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-436940714252520724.post-6496070764248710444</id><published>2011-10-05T09:39:00.001-05:00</published><updated>2011-10-05T09:39:30.630-05:00</updated><title type='text'>Cambiar el nombre a una tabla</title><content type='html'>&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;EXECUTE sp_rename &#39;[dbo].[Clients]&#39;, &#39;Customers&#39;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://instruccionsql.blogspot.com/feeds/6496070764248710444/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/cambiar-el-nombre-una-tabla.html#comment-form' title='1 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/6496070764248710444'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/6496070764248710444'/><link rel='alternate' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/cambiar-el-nombre-una-tabla.html' title='Cambiar el nombre a una tabla'/><author><name>Edd</name><uri>http://www.blogger.com/profile/09985292416186758161</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-436940714252520724.post-6990797252921604724</id><published>2011-10-05T09:38:00.001-05:00</published><updated>2011-10-05T09:38:13.922-05:00</updated><title type='text'>Importar desde Excel a SQL</title><content type='html'>&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;If Object_id(&#39;tempdb..#tmpArchivo&#39;) is not null Drop Table #tmpArchivo&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Create table #tmpArchivo (Num float,Nombre varchar(100),Apellido varchar(100),Direccion varchar(100))&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;Insert into #tmpArchivo&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;SELECT * FROM OPENROWSET(&#39;Microsoft.Jet.OLEDB.4.0&#39;,&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;Excel 8.0;Database=E:\Siopfile\Archivo.xls&#39;,&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;SELECT * FROM [Dir$]&#39;)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;--Leer Excel en caso de que no tenga Cabecera cada columna&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;SELECT * &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;FROM OPENROWSET(&#39;Microsoft.Jet.OLEDB.4.0&#39;,&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;Excel 8.0;Database=C:\Source\Addresses.xls;HDR=No&#39;,&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;SELECT * FROM [Sheet1$]&#39;)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;--Para indicar que las columnas tienen diferentes tipos (Ej: q venga en el CP numeros y letras)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;SELECT&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;* FROM OPENROWSET(&#39;Microsoft.Jet.OLEDB.4.0&#39;,&#39;Excel8.0;Database=C:\Source\Addresses.xls;HDR=No;IMEX=1&#39;,&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;SELECT * FROM [Sheet1$]&#39;)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;--Para importar directo a una tabla SQL&amp;gt;Excel&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;SELECT * into #tmpArchivo2 FROM OPENROWSET(&#39;Microsoft.Jet.OLEDB.4.0&#39;,&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;Excel 8.0;Database=E:\Siopfile\Archivo.xls&#39;,&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;SELECT * FROM [Dir$]&#39;)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;--Para importar con el tipo de datos correcto&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;SELECT CAST([FirstName] AS VARCHAR(20)) AS [FirstName],&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CAST([LastName] AS VARCHAR(20)) AS [LastName],&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CAST([Address] AS VARCHAR(50)) AS [Address],&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CAST([City] AS VARCHAR(30)) AS [City],&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CAST([State] AS VARCHAR(2)) AS [State],&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CAST([ZIP] AS VARCHAR(10)) AS [ZIP]&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;INTO [dbo].[Addresses_Temp]&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;FROM OPENROWSET(&#39;Microsoft.Jet.OLEDB.4.0&#39;,&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;Excel 8.0;Database=C:\Source\Addresses.xls;IMEX=1&#39;,&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;SELECT * FROM [Sheet1$]&#39;)&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;</content><link rel='replies' type='application/atom+xml' href='http://instruccionsql.blogspot.com/feeds/6990797252921604724/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/importar-desde-excel-sql.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/6990797252921604724'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/6990797252921604724'/><link rel='alternate' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/importar-desde-excel-sql.html' title='Importar desde Excel a SQL'/><author><name>Edd</name><uri>http://www.blogger.com/profile/09985292416186758161</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-436940714252520724.post-763185229885865760</id><published>2011-10-05T09:37:00.001-05:00</published><updated>2011-10-05T09:37:22.786-05:00</updated><title type='text'>Guardar el resultado en plantilla HTML</title><content type='html'>&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;USE pubs&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;GO&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;EXECUTE sp_makewebtask @outputfile = &#39;C:\MULTIPLE.HTM&#39;,&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;@query = &#39;SELECT title, price FROM titles SELECT au_lname, au_fname &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;FROM authors SELECT pub_id, pub_name FROM publishers SELECT au_lname, &lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;au_fname FROM authors&#39;, @templatefile = &#39;C:\MULTIPLE.TPL&#39;,&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;@dbname = &#39;pubs&#39;, @rowcnt = 5, @whentype = 9&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;GO&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;br /&gt;--Se requiere esta plantilla&lt;br /&gt;&amp;lt;HTML&amp;gt;&amp;nbsp; &lt;br /&gt;&amp;lt;HEAD&amp;gt;&amp;nbsp; &lt;br /&gt;&amp;lt;TITLE&amp;gt;SQL Server Multiple Queries with Template Web Sample&amp;lt;/TITLE&amp;gt;&amp;nbsp; &lt;br /&gt;&amp;lt;BODY&amp;gt;&amp;nbsp; &lt;br /&gt;&amp;lt;H1&amp;gt;Books For Sale&amp;lt;/H1&amp;gt;&lt;br /&gt;&amp;lt;HR&amp;gt;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;lt;P&amp;gt;&lt;br /&gt;&amp;lt;TABLE BORDER&amp;gt;&lt;br /&gt;&amp;lt;TR&amp;gt; &amp;lt;TH&amp;gt;&amp;lt;I&amp;gt;Title&amp;lt;/I&amp;gt;&amp;lt;/TH&amp;gt; &amp;lt;TH&amp;gt;&amp;lt;B&amp;gt;Price&amp;lt;/B&amp;gt;&amp;lt;/TH&amp;gt; &amp;lt;/TR&amp;gt;&lt;br /&gt;&amp;lt;%begindetail%&amp;gt;&lt;br /&gt;&amp;lt;TR&amp;gt; &amp;lt;TD&amp;gt;&amp;lt;I&amp;gt; &amp;lt;%insert_data_here%&amp;gt; &amp;lt;/I&amp;gt; &amp;lt;/TD&amp;gt;&lt;br /&gt;&amp;lt;TD ALIGN=RIGHT&amp;gt;&amp;lt;B&amp;gt; $&amp;lt;%insert_data_here%&amp;gt;&amp;lt;/B&amp;gt;&amp;lt;/TD&amp;gt; &amp;lt;/TR&amp;gt;&lt;br /&gt;&amp;lt;%enddetail%&amp;gt;&lt;br /&gt;&amp;lt;/TABLE&amp;gt;&lt;br /&gt;&amp;lt;P&amp;gt;&amp;nbsp; &lt;br /&gt;&amp;lt;HR&amp;gt;&amp;nbsp; &lt;br /&gt;&amp;lt;%insert_data_here%&amp;gt; &lt;br /&gt;&amp;lt;P&amp;gt;&amp;nbsp; &lt;br /&gt;&amp;lt;TABLE BORDER&amp;gt;&lt;br /&gt;&amp;lt;TR&amp;gt; &amp;lt;TH ALIGN=CENTER&amp;gt;ID&amp;lt;/TH&amp;gt; &amp;lt;TH ALIGN=LEFT&amp;gt;&amp;lt;I&amp;gt;Publishers Name&amp;lt;/I&amp;gt;&amp;lt;/TH&amp;gt; &amp;lt;/TR&amp;gt;&amp;lt;%begindetail%&amp;gt;&lt;br /&gt;&amp;lt;TR&amp;gt; &amp;lt;TD&amp;gt; &amp;lt;%insert_data_here%&amp;gt; &amp;lt;/TD&amp;gt;&lt;br /&gt;&amp;lt;TD ALIGN=LEFT&amp;gt;&amp;lt;I&amp;gt; &amp;lt;%insert_data_here%&amp;gt;&amp;lt;/I&amp;gt;&amp;lt;/TD&amp;gt; &amp;lt;/TR&amp;gt;&amp;lt;%enddetail%&amp;gt;&lt;br /&gt;&amp;lt;/TABLE&amp;gt;&lt;br /&gt;&amp;lt;HR&amp;gt;&lt;br /&gt;&amp;lt;%insert_data_here%&amp;gt;&lt;br /&gt;&amp;lt;P&amp;gt;&lt;br /&gt;&amp;lt;A HREF = &quot;http://www.microsoft.com&quot;&amp;gt;Microsoft&amp;lt;/A&amp;gt;&amp;lt;P&amp;gt;&lt;br /&gt;&amp;lt;A HREF = &quot;http://msdn.microsoft.com&quot;&amp;gt;MSDN&amp;lt;/A&amp;gt;&amp;lt;P&amp;gt;&lt;br /&gt;&amp;lt;/BODY&amp;gt;&lt;br /&gt;&amp;lt;/HTML&amp;gt;</content><link rel='replies' type='application/atom+xml' href='http://instruccionsql.blogspot.com/feeds/763185229885865760/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/guardar-el-resultado-en-plantilla-html.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/763185229885865760'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/763185229885865760'/><link rel='alternate' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/guardar-el-resultado-en-plantilla-html.html' title='Guardar el resultado en plantilla HTML'/><author><name>Edd</name><uri>http://www.blogger.com/profile/09985292416186758161</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-436940714252520724.post-96078672810157920</id><published>2011-10-05T09:36:00.001-05:00</published><updated>2011-10-05T09:36:25.430-05:00</updated><title type='text'>Escribir a un archivo de texto (ver 2)</title><content type='html'>&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;master..xp_cmdshell &#39;bcp master..sysobjects out c:\file.bcp -S -U -P -c &#39;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;exec master..xp_cmdshell &#39;echo hello &amp;gt; c:\file.txt&#39;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;exec master..xp_cmdshell &#39;echo appended data &amp;gt;&amp;gt; c:\file.txt&#39;&lt;/span&gt;&lt;br style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot; /&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;exec master..xp_cmdshell &#39;echo more data &amp;gt;&amp;gt; c:\file.txt&#39;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://instruccionsql.blogspot.com/feeds/96078672810157920/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/escribir-un-archivo-de-texto-ver-2.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/96078672810157920'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/436940714252520724/posts/default/96078672810157920'/><link rel='alternate' type='text/html' href='http://instruccionsql.blogspot.com/2011/10/escribir-un-archivo-de-texto-ver-2.html' title='Escribir a un archivo de texto (ver 2)'/><author><name>Edd</name><uri>http://www.blogger.com/profile/09985292416186758161</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>