<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>SQL Como Um Todo</title>
	<atom:link href="http://sqlcomoumtodo.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://sqlcomoumtodo.wordpress.com</link>
	<description>Tudo e mais um pouco de SQL</description>
	<lastBuildDate>Mon, 08 Sep 2008 18:51:28 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>pt-br</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='sqlcomoumtodo.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/fdeebb1cf5fbe65e52d1bbeb5a65305a?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>SQL Como Um Todo</title>
		<link>http://sqlcomoumtodo.wordpress.com</link>
	</image>
			<item>
		<title>Função de formatação de números</title>
		<link>http://sqlcomoumtodo.wordpress.com/2008/09/08/funcao-de-formatacao-de-numeros/</link>
		<comments>http://sqlcomoumtodo.wordpress.com/2008/09/08/funcao-de-formatacao-de-numeros/#comments</comments>
		<pubDate>Mon, 08 Sep 2008 18:51:28 +0000</pubDate>
		<dc:creator>Alexandre Araujo</dc:creator>
				<category><![CDATA[Consulta]]></category>
		<category><![CDATA[Funções]]></category>
		<category><![CDATA[Programação]]></category>
		<category><![CDATA[Query]]></category>
		<category><![CDATA[SELECT]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[sql function função format formatação consulta]]></category>

		<guid isPermaLink="false">http://sqlcomoumtodo.wordpress.com/?p=54</guid>
		<description><![CDATA[Recebi um e-mail de um internauta que criou uma função em SQL que formata números. A função é bastante simples e pede apenas três parâmetros: valor, separador do milhar e separador decimal.
Segue abaixo o código:
CREATE FUNCTION FormataValor(@Valor DECIMAL(18,2),@SepMilhar CHAR(1),@SepDecimal CHAR(1))
RETURNS  VARCHAR(100) AS
BEGIN
DECLARE @inteiro VARCHAR(98),
@Texto VARCHAR(100),
@decimal VARCHAR(2),
@retorno VARCHAR(100)
SET @Texto = RTRIM(CAST(@Valor AS VARCHAR(50)))
SET @inteiro = CAST(CAST(@Valor [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcomoumtodo.wordpress.com&blog=1803981&post=54&subd=sqlcomoumtodo&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Recebi um e-mail de um internauta que criou uma função em SQL que formata números. A função é bastante simples e pede apenas três parâmetros: <strong>valor</strong>, <strong>separador do milhar</strong> e <strong>separador decimal</strong>.</p>
<p>Segue abaixo o código:<br />
CREATE FUNCTION FormataValor(@Valor DECIMAL(18,2),@SepMilhar CHAR(1),@SepDecimal CHAR(1))<br />
RETURNS  VARCHAR(100) AS<br />
BEGIN<br />
DECLARE @inteiro VARCHAR(98),<br />
@Texto VARCHAR(100),<br />
@decimal VARCHAR(2),<br />
@retorno VARCHAR(100)</p>
<p>SET @Texto = RTRIM(CAST(@Valor AS VARCHAR(50)))<br />
SET @inteiro = CAST(CAST(@Valor AS INTEGER) AS VARCHAR(180))<br />
SET @decimal = SUBSTRING(@Texto, LEN(@Texto)-1,2)<br />
SET @retorno = &#8221;</p>
<p>WHILE (LEN(@inteiro) &amp;gt; 3)<br />
BEGIN<br />
SET @retorno = @SepMilhar + SUBSTRING(@inteiro, LEN(@inteiro)-2, 3) + @retorno<br />
SET @inteiro = SUBSTRING(@inteiro, 1, len(@inteiro)-3)<br />
END</p>
<p>SET @retorno = @inteiro + @retorno<br />
SET @retorno = @retorno + @SepDecimal + @decimal</p>
<p>RETURN @retorno<br />
END</p>
<p>Crédito: <strong>Helder</strong></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sqlcomoumtodo.wordpress.com/54/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sqlcomoumtodo.wordpress.com/54/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlcomoumtodo.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlcomoumtodo.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlcomoumtodo.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlcomoumtodo.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlcomoumtodo.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlcomoumtodo.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlcomoumtodo.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlcomoumtodo.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlcomoumtodo.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlcomoumtodo.wordpress.com/54/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcomoumtodo.wordpress.com&blog=1803981&post=54&subd=sqlcomoumtodo&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://sqlcomoumtodo.wordpress.com/2008/09/08/funcao-de-formatacao-de-numeros/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2f52b3927451451e9b8c69711aca639a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">alexandregavazza</media:title>
		</media:content>
	</item>
		<item>
		<title>Retornando uma consulta SQL em XML</title>
		<link>http://sqlcomoumtodo.wordpress.com/2008/02/21/retornando-uma-consulta-sql-em-xml/</link>
		<comments>http://sqlcomoumtodo.wordpress.com/2008/02/21/retornando-uma-consulta-sql-em-xml/#comments</comments>
		<pubDate>Thu, 21 Feb 2008 18:49:16 +0000</pubDate>
		<dc:creator>Alexandre Araujo</dc:creator>
				<category><![CDATA[Consulta]]></category>
		<category><![CDATA[Programação]]></category>
		<category><![CDATA[Query]]></category>
		<category><![CDATA[SELECT]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://sqlcomoumtodo.wordpress.com/?p=53</guid>
		<description><![CDATA[Depois de algum tempo sem postar, estou de volta. Estive um pouco ocupado e em busca de novos conhecimentos. Mas chega de ficar falando besteira e vamos ao que realmente interessa.
Estive pesquisando e encontrei uma maneira de gerar a saída de uma consulta no formato XML utilizando uma consulta em SQL.
SELECT
Clientes.ID,
Pedidos.Descricao,
Clientes.Nome
FROM
Clientes,
Pedidos
WHERE
Clientes.Nome LIKE &#8216;%Alexandre%&#8217;
ORDER BY
Pedidos.ID
FOR XML [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcomoumtodo.wordpress.com&blog=1803981&post=53&subd=sqlcomoumtodo&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Depois de algum tempo sem postar, estou de volta. Estive um pouco ocupado e em busca de novos conhecimentos. Mas chega de ficar falando besteira e vamos ao que realmente interessa.</p>
<p>Estive pesquisando e encontrei uma maneira de gerar a saída de uma consulta no formato XML utilizando uma consulta em SQL.</p>
<p>SELECT</p>
<blockquote><p>Clientes.ID,</p>
<p>Pedidos.Descricao,</p>
<p>Clientes.Nome</p></blockquote>
<p>FROM</p>
<blockquote><p>Clientes,</p>
<p>Pedidos</p></blockquote>
<p>WHERE</p>
<blockquote><p>Clientes.Nome LIKE &#8216;%Alexandre%&#8217;</p></blockquote>
<p>ORDER BY</p>
<blockquote><p>Pedidos.ID</p></blockquote>
<p>FOR XML AUTO</p>
<p>A consulta acima exibirá como resultado (em formato XML) os clientes que contenham &#8216;Alexandre&#8217; no nome ordenando pelo(s) pedido(s) existente(s).</p>
<p>A cláusula <strong>AUTO</strong> cria uma hierarquia dos elementos retornados automaticamente. Ex.: Existe o cliente &#8216;Alexandre&#8217; e o mesmo possue dois pedidos, neste caso o retorno do XML será similar a este:</p>
<p>&lt;Clientes ID=&#8221;1&#8243; Nome=&#8221;Alexandre&#8221;&gt;</p>
<blockquote><p>&lt;Pedidos Descricao=&#8221;Pedido Pendrive 4GB&#8221;/&gt;</p>
<p>&lt;Pedidos Descricao=&#8221;Pedido Televisor 29pol&#8221;/&gt;</p></blockquote>
<p>&lt;/Clientes&gt;</p>
<p>Os nós de pedidos estão entre os clientes, criando assim uma hierarquia.</p>
<p>Provavelmente continuarei este artigo posteriormente, porque existe outras maneiras de utilizar esta técnica. Até a próxima.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sqlcomoumtodo.wordpress.com/53/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sqlcomoumtodo.wordpress.com/53/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlcomoumtodo.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlcomoumtodo.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlcomoumtodo.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlcomoumtodo.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlcomoumtodo.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlcomoumtodo.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlcomoumtodo.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlcomoumtodo.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlcomoumtodo.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlcomoumtodo.wordpress.com/53/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcomoumtodo.wordpress.com&blog=1803981&post=53&subd=sqlcomoumtodo&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://sqlcomoumtodo.wordpress.com/2008/02/21/retornando-uma-consulta-sql-em-xml/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2f52b3927451451e9b8c69711aca639a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">alexandregavazza</media:title>
		</media:content>
	</item>
		<item>
		<title>Acessando remotamente um servidor em SQL</title>
		<link>http://sqlcomoumtodo.wordpress.com/2007/12/04/43/</link>
		<comments>http://sqlcomoumtodo.wordpress.com/2007/12/04/43/#comments</comments>
		<pubDate>Tue, 04 Dec 2007 17:27:07 +0000</pubDate>
		<dc:creator>Alexandre Araujo</dc:creator>
				<category><![CDATA[Ferramentas]]></category>
		<category><![CDATA[ferramenta]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[utilidade]]></category>

		<guid isPermaLink="false">http://sqlcomoumtodo.wordpress.com/2007/12/04/43/</guid>
		<description><![CDATA[Vou abordar no blog um assunto um pouco diferente dos anteriores, explicarei passo-a-passo de como criar uma conexão com um servidor remoto em uma mesma rede.
Primeiramente abra o SQL Server Enterprise Manager, após a abertura, maximize a raiz Microsoft SQL Servers e logo após o SQL Server Group. Feito isto, clique com o botão direito [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcomoumtodo.wordpress.com&blog=1803981&post=43&subd=sqlcomoumtodo&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Vou abordar no blog um assunto um pouco diferente dos anteriores, explicarei passo-a-passo de como criar uma conexão com um servidor remoto em uma mesma rede.</p>
<p>Primeiramente abra o <strong>SQL Server Enterprise Manager</strong>, após a abertura, maximize a raiz <strong>Microsoft SQL Servers</strong> e logo após o <strong>SQL Server Group</strong>. Feito isto, clique com o botão direito sobre o item <strong>SQL Server Group</strong>.</p>
<p><a href="http://sqlcomoumtodo.files.wordpress.com/2007/12/sql_registration_img1.png" title="SQL Server Group"><img src="http://sqlcomoumtodo.files.wordpress.com/2007/12/sql_registration_img1.png" alt="SQL Server Group" /></a></p>
<p>Abrirá uma janela com o título de <strong>Register SQL Server Wizard</strong>, clique avançar para prosseguir. Será listado todos os servidores encontrados pelo <strong>SQL Server</strong> na rede, selecione o(s) servidor(es) de escolha e clique <strong>Add</strong> para adicionar, avançar novamente.</p>
<p><a href="http://sqlcomoumtodo.files.wordpress.com/2007/12/sql_registration_img2.png" title="Register SQL Server Wizard"><img src="http://sqlcomoumtodo.files.wordpress.com/2007/12/sql_registration_img2.png" alt="Register SQL Server Wizard" /></a></p>
<p>Selecione o tipo de autenticação, sendo que o primeiro é o login e senha do próprio <strong>Windows</strong> e o segundo é referente ao <strong>SQL Server</strong>.</p>
<p><a href="http://sqlcomoumtodo.files.wordpress.com/2007/12/sql_registration_img3.png" title="Authentication Mode"><img src="http://sqlcomoumtodo.files.wordpress.com/2007/12/sql_registration_img3.png" alt="Authentication Mode" /></a></p>
<p>Em seguida será mostrado o local onde deseja adicionar a conexão. A primeira corresponde à grupos já existentes e a segunda pede-se para criar um grupo. Clique avançar para prosseguir.</p>
<p><a href="http://sqlcomoumtodo.files.wordpress.com/2007/12/sql_registration_img4.png" title="Seleção do Grupo"><img src="http://sqlcomoumtodo.files.wordpress.com/2007/12/sql_registration_img4.png" alt="Seleção do Grupo" /></a></p>
<p>Pronto, após feito estes procedimentos a conexão está pronta para ser usada.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sqlcomoumtodo.wordpress.com/43/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sqlcomoumtodo.wordpress.com/43/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlcomoumtodo.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlcomoumtodo.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlcomoumtodo.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlcomoumtodo.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlcomoumtodo.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlcomoumtodo.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlcomoumtodo.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlcomoumtodo.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlcomoumtodo.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlcomoumtodo.wordpress.com/43/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcomoumtodo.wordpress.com&blog=1803981&post=43&subd=sqlcomoumtodo&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://sqlcomoumtodo.wordpress.com/2007/12/04/43/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2f52b3927451451e9b8c69711aca639a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">alexandregavazza</media:title>
		</media:content>

		<media:content url="http://sqlcomoumtodo.files.wordpress.com/2007/12/sql_registration_img1.png" medium="image">
			<media:title type="html">SQL Server Group</media:title>
		</media:content>

		<media:content url="http://sqlcomoumtodo.files.wordpress.com/2007/12/sql_registration_img2.png" medium="image">
			<media:title type="html">Register SQL Server Wizard</media:title>
		</media:content>

		<media:content url="http://sqlcomoumtodo.files.wordpress.com/2007/12/sql_registration_img3.png" medium="image">
			<media:title type="html">Authentication Mode</media:title>
		</media:content>

		<media:content url="http://sqlcomoumtodo.files.wordpress.com/2007/12/sql_registration_img4.png" medium="image">
			<media:title type="html">Seleção do Grupo</media:title>
		</media:content>
	</item>
		<item>
		<title>Usando o CHARINDEX em SQL</title>
		<link>http://sqlcomoumtodo.wordpress.com/2007/12/03/usando-o-charindex-em-sql/</link>
		<comments>http://sqlcomoumtodo.wordpress.com/2007/12/03/usando-o-charindex-em-sql/#comments</comments>
		<pubDate>Mon, 03 Dec 2007 13:22:32 +0000</pubDate>
		<dc:creator>Alexandre Araujo</dc:creator>
				<category><![CDATA[CHARINDEX]]></category>
		<category><![CDATA[Consulta]]></category>
		<category><![CDATA[Funções]]></category>
		<category><![CDATA[Programação]]></category>
		<category><![CDATA[Query]]></category>
		<category><![CDATA[SELECT]]></category>

		<guid isPermaLink="false">http://sqlcomoumtodo.wordpress.com/2007/12/03/usando-o-charindex-em-sql/</guid>
		<description><![CDATA[O CHARINDEX é uma função em SQL que retorna a primeira posição de uma sequencia de caracteres em uma determinada expressão. A primeira posição de contagem é 1.
Sintaxe:
CHARINDEX(expressao1, expressao2 [, posicao_inicial])
expressao1: É onde contém a sequencia de caracteres a ser encontrado.
expressao2: É onde contém a sequencia de caracteres que será feito a busca. Geralmente, é [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcomoumtodo.wordpress.com&blog=1803981&post=38&subd=sqlcomoumtodo&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>O <strong>CHARINDEX </strong>é uma função em <strong>SQL </strong>que retorna a primeira posição de uma sequencia de caracteres em uma determinada expressão. A primeira posição de contagem é 1.</p>
<p>Sintaxe:</p>
<p>CHARINDEX<em>(expressao1</em>, <em>expressao2 </em>[, <em>posicao_inicial</em>])</p>
<p><em>expressao1</em>: É onde contém a sequencia de caracteres a ser encontrado.<br />
<em>expressao2</em>: É onde contém a sequencia de caracteres que será feito a busca. Geralmente, é usado uma coluna de um campo.<br />
<em>posicao_inicial</em>: É um parâmetro opcional, que deve-se colocar a posição inicial da busca, caso omitido, será iniciado do zero.</p>
<p>Segue abaixo a sintaxe:</p>
<p>SELECT</p>
<blockquote><p>Nome,</p></blockquote>
<blockquote><p>CHARINDEX(&#8216;papel&#8217;, Nome) AS Posicao</p></blockquote>
<p>FROM</p>
<blockquote><p>Produto</p></blockquote>
<p>Na situação acima a busca será iniciada na primeira posição do campo &#8216;Nome&#8217; da tabela &#8216;Produto&#8217;, porque o último parâmetro que indica a posição inicial de busca foi omitido.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sqlcomoumtodo.wordpress.com/38/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sqlcomoumtodo.wordpress.com/38/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlcomoumtodo.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlcomoumtodo.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlcomoumtodo.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlcomoumtodo.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlcomoumtodo.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlcomoumtodo.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlcomoumtodo.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlcomoumtodo.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlcomoumtodo.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlcomoumtodo.wordpress.com/38/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcomoumtodo.wordpress.com&blog=1803981&post=38&subd=sqlcomoumtodo&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://sqlcomoumtodo.wordpress.com/2007/12/03/usando-o-charindex-em-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2f52b3927451451e9b8c69711aca639a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">alexandregavazza</media:title>
		</media:content>
	</item>
		<item>
		<title>Como inventer os caracteres em SQL</title>
		<link>http://sqlcomoumtodo.wordpress.com/2007/11/22/como-inventer-os-caracteres-em-sql/</link>
		<comments>http://sqlcomoumtodo.wordpress.com/2007/11/22/como-inventer-os-caracteres-em-sql/#comments</comments>
		<pubDate>Thu, 22 Nov 2007 13:58:46 +0000</pubDate>
		<dc:creator>Alexandre Araujo</dc:creator>
				<category><![CDATA[Consulta]]></category>
		<category><![CDATA[Funções]]></category>
		<category><![CDATA[Programação]]></category>
		<category><![CDATA[Query]]></category>
		<category><![CDATA[SELECT]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[função]]></category>
		<category><![CDATA[REVERSE]]></category>

		<guid isPermaLink="false">http://sqlcomoumtodo.wordpress.com/2007/11/22/como-inventer-os-caracteres-em-sql/</guid>
		<description><![CDATA[O SQL possui uma função que faz a inverção dos caracteres passados como parâmetro. O parâmetro informado pode ser constante, variáveis, colunas retornadas de um campo e até mesmo um números, seu resultado sempre será VARCHAR.
Sintaxe:
REVERSE(expressão)
SELECT REVERSE(&#8216;Alexandre&#8217;) AS &#8216;Nome&#8217;
O resultado da consulta acima será &#8216;erdnaxelA&#8217;, preservando os caracteres maiúsculos e/ou minúsculos.
     [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcomoumtodo.wordpress.com&blog=1803981&post=37&subd=sqlcomoumtodo&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>O <strong><a href="http://pt.wikipedia.org/wiki/SQL" title="O que é SQL?">SQL</a> </strong>possui uma função que faz a inverção dos caracteres passados como parâmetro. O parâmetro informado pode ser constante, variáveis, colunas retornadas de um campo e até mesmo um números, seu resultado sempre será <strong>VARCHAR</strong>.</p>
<p>Sintaxe:</p>
<p>REVERSE(expressão)</p>
<p>SELECT REVERSE(&#8216;Alexandre&#8217;) AS &#8216;Nome&#8217;</p>
<p>O resultado da consulta acima será &#8216;erdnaxelA&#8217;, preservando os caracteres maiúsculos e/ou minúsculos.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sqlcomoumtodo.wordpress.com/37/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sqlcomoumtodo.wordpress.com/37/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlcomoumtodo.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlcomoumtodo.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlcomoumtodo.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlcomoumtodo.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlcomoumtodo.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlcomoumtodo.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlcomoumtodo.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlcomoumtodo.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlcomoumtodo.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlcomoumtodo.wordpress.com/37/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcomoumtodo.wordpress.com&blog=1803981&post=37&subd=sqlcomoumtodo&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://sqlcomoumtodo.wordpress.com/2007/11/22/como-inventer-os-caracteres-em-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2f52b3927451451e9b8c69711aca639a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">alexandregavazza</media:title>
		</media:content>
	</item>
		<item>
		<title>Quantidade de processamento em SQL</title>
		<link>http://sqlcomoumtodo.wordpress.com/2007/11/22/quantidade-de-processamento-em-sql/</link>
		<comments>http://sqlcomoumtodo.wordpress.com/2007/11/22/quantidade-de-processamento-em-sql/#comments</comments>
		<pubDate>Thu, 22 Nov 2007 13:48:41 +0000</pubDate>
		<dc:creator>Alexandre Araujo</dc:creator>
				<category><![CDATA[CPU_BUSY]]></category>
		<category><![CDATA[Consulta]]></category>
		<category><![CDATA[Query]]></category>
		<category><![CDATA[SELECT]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://sqlcomoumtodo.wordpress.com/2007/11/22/quantidade-de-processamento-em-sql/</guid>
		<description><![CDATA[A palavra-chave @@CPU_BUSY retorna o tempo em milisegundos que a CPU está utilizando desde a última inicialização do SQL Server.
Veja abaixo um exemplo de como usar este recurso:
SELECT @@CPU_BUSY AS &#8216;CPU ms&#8217;, GETDATE() AS &#8216;Até&#8217;
Acima será mostrado a quantidade de processamento que a CPU utilizou até o momento da data.
      [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcomoumtodo.wordpress.com&blog=1803981&post=36&subd=sqlcomoumtodo&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>A palavra-chave <strong>@@CPU_BUSY</strong> retorna o tempo em milisegundos que a CPU está utilizando desde a última inicialização do SQL Server.</p>
<p>Veja abaixo um exemplo de como usar este recurso:</p>
<p>SELECT @@CPU_BUSY AS &#8216;CPU ms&#8217;, GETDATE() AS &#8216;Até&#8217;</p>
<p>Acima será mostrado a quantidade de processamento que a CPU utilizou até o momento da data.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sqlcomoumtodo.wordpress.com/36/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sqlcomoumtodo.wordpress.com/36/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlcomoumtodo.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlcomoumtodo.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlcomoumtodo.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlcomoumtodo.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlcomoumtodo.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlcomoumtodo.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlcomoumtodo.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlcomoumtodo.wordpress.com/36/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlcomoumtodo.wordpress.com/36/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlcomoumtodo.wordpress.com/36/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcomoumtodo.wordpress.com&blog=1803981&post=36&subd=sqlcomoumtodo&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://sqlcomoumtodo.wordpress.com/2007/11/22/quantidade-de-processamento-em-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2f52b3927451451e9b8c69711aca639a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">alexandregavazza</media:title>
		</media:content>
	</item>
		<item>
		<title>Alterando / Removendo campos de uma tabela em SQL</title>
		<link>http://sqlcomoumtodo.wordpress.com/2007/11/10/alterando-removendo-campos-de-uma-tabela-em-sql/</link>
		<comments>http://sqlcomoumtodo.wordpress.com/2007/11/10/alterando-removendo-campos-de-uma-tabela-em-sql/#comments</comments>
		<pubDate>Sat, 10 Nov 2007 14:34:18 +0000</pubDate>
		<dc:creator>Alexandre Araujo</dc:creator>
				<category><![CDATA[ALTER]]></category>
		<category><![CDATA[Consulta]]></category>
		<category><![CDATA[Programação]]></category>
		<category><![CDATA[Query]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[TABLE]]></category>

		<guid isPermaLink="false">http://sqlcomoumtodo.wordpress.com/2007/11/10/alterando-removendo-campos-de-uma-tabela-em-sql/</guid>
		<description><![CDATA[O ALTER TABLE é usado para adicionar e/ou remover colunas de uma determinada tabela que esteja em um base de dados. Para isto é necessário informar o nome da tabela, o campo da tabela e caso seja uma adição, será necessário passar o tipo do novo campo.
ALTER TABLE
Cliente
ADD
CPF CHAR(11)
Acima foi criado o campo &#8216;CPF&#8217; na [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcomoumtodo.wordpress.com&blog=1803981&post=35&subd=sqlcomoumtodo&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>O <strong>ALTER TABLE</strong> é usado para adicionar e/ou remover colunas de uma determinada tabela que esteja em um base de dados. Para isto é necessário informar o nome da tabela, o campo da tabela e caso seja uma adição, será necessário passar o tipo do novo campo.</p>
<p>ALTER TABLE</p>
<blockquote><p>Cliente</p></blockquote>
<p>ADD</p>
<blockquote><p>CPF CHAR(11)</p></blockquote>
<p>Acima foi criado o campo &#8216;CPF&#8217; na tabela &#8216;Cliente&#8217; com o tipo <strong>CHAR</strong>. Para que o campo aceite valores nulos (<strong>NULL</strong>), basta adicionar o operador &#8216;=&#8217; e em seguida a palavra <strong>NULL</strong>.</p>
<p>Já para remover um campo de uma tabela é ainda mais simples, não havendo a necessidade de inserir o tipo do campo.</p>
<p>ALTER TABLE</p>
<blockquote><p>Cliente</p></blockquote>
<p>DROP COLUMN</p>
<blockquote><p>CPF</p></blockquote>
<p>Lembrando que, ao remover um campo de uma tabela, não haverá a possibilidade de voltar atrás (não pelo meu conhecimento), a não ser que faça um backup manual ou algo parecido.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sqlcomoumtodo.wordpress.com/35/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sqlcomoumtodo.wordpress.com/35/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlcomoumtodo.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlcomoumtodo.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlcomoumtodo.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlcomoumtodo.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlcomoumtodo.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlcomoumtodo.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlcomoumtodo.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlcomoumtodo.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlcomoumtodo.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlcomoumtodo.wordpress.com/35/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcomoumtodo.wordpress.com&blog=1803981&post=35&subd=sqlcomoumtodo&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://sqlcomoumtodo.wordpress.com/2007/11/10/alterando-removendo-campos-de-uma-tabela-em-sql/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2f52b3927451451e9b8c69711aca639a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">alexandregavazza</media:title>
		</media:content>
	</item>
		<item>
		<title>Como saber as características de um objeto em SQL</title>
		<link>http://sqlcomoumtodo.wordpress.com/2007/11/07/como-saber-as-caracteristicas-de-um-objeto-em-sql/</link>
		<comments>http://sqlcomoumtodo.wordpress.com/2007/11/07/como-saber-as-caracteristicas-de-um-objeto-em-sql/#comments</comments>
		<pubDate>Wed, 07 Nov 2007 19:36:03 +0000</pubDate>
		<dc:creator>Alexandre Araujo</dc:creator>
				<category><![CDATA[Consulta]]></category>
		<category><![CDATA[Funções]]></category>
		<category><![CDATA[OBJECT_PROPERTY]]></category>
		<category><![CDATA[Query]]></category>
		<category><![CDATA[SELECT]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://sqlcomoumtodo.wordpress.com/2007/11/07/como-saber-as-caracteristicas-de-um-objeto-em-sql/</guid>
		<description><![CDATA[A linguagem SQL possui uma função que exibe informações sobre todos os objetos existentes na base de dados.
Sintaxe:
OBJECTPROPERTY(id, propriedade)
Argumentos:
id -&#62; É a identificação do objeto na base de dados, ou seja, uma identificação única e que pode ser encontrada na tabela sysobjects. Lembrando que este argumente DEVE ser do tipo inteiro.
propriedade -&#62; É onde insere [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcomoumtodo.wordpress.com&blog=1803981&post=31&subd=sqlcomoumtodo&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>A linguagem <strong><a href="http://pt.wikipedia.org/wiki/SQL" title="O que é SQL?">SQL</a></strong> possui uma função que exibe informações sobre todos os <a href="http://pt.wikipedia.org/wiki/Objeto" title="O que é objeto?">objetos</a> existentes na <a href="http://pt.wikipedia.org/wiki/Base_de_dados" title="O que é base de dados?">base de dados</a>.</p>
<p><strong>Sintaxe:</strong></p>
<p>OBJECTPROPERTY(id, propriedade)</p>
<p><strong>Argumentos:</strong></p>
<p><em>id</em> -&gt; É a identificação do objeto na base de dados, ou seja, uma identificação única e que pode ser encontrada na tabela <strong>sysobjects</strong>. Lembrando que este argumente <strong>DEVE </strong>ser do tipo inteiro.<br />
<em>propriedade </em>-&gt; É onde insere a expressão que se deseja obter sobre o objeto.</p>
<p>Segue abaixo todas as propriedades existentes no <strong>SQL Server</strong>:</p>
<table width="410">
<tr>
<td style="border:1px solid #000000;" align="center" width="30%"><strong>Property name</strong></td>
<td style="border:1px solid #000000;" align="center" width="20%"><strong>Object type</strong></td>
<td style="border:1px solid #000000;" align="center"><strong>Description and values returned</strong></td>
</tr>
<tr>
<td style="border:1px solid #000000;">CnstIsClustKey</td>
<td style="border:1px solid #000000;" align="center">Constraint</td>
<td style="border:1px solid #000000;">A primary key with a clustered index.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">CnstIsColumn</td>
<td style="border:1px solid #000000;" align="center">Constraint</td>
<td style="border:1px solid #000000;">COLUMN constraint.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">CnstIsDeleteCascade</td>
<td style="border:1px solid #000000;" align="center">Constraint</td>
<td style="border:1px solid #000000;">A foreign key constraint with the ON DELETE CASCADE<br />
option.</td>
</tr>
<tr>
<td style="border:1px solid #000000;">CnstIsDisabled</td>
<td style="border:1px solid #000000;" align="center">Constraint</td>
<td style="border:1px solid #000000;">Disabled constraint.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">CnstIsNonclustKey</td>
<td style="border:1px solid #000000;" align="center">Constraint</td>
<td style="border:1px solid #000000;">A primary key with a nonclustered index.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">CnstIsNotTrusted</td>
<td style="border:1px solid #000000;" align="center">Constraint</td>
<td style="border:1px solid #000000;">Constraint was enabled without checking existing rows, so constraint may not hold for all rows.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">CnstIsNotRepl</td>
<td style="border:1px solid #000000;" align="center">Constraint</td>
<td style="border:1px solid #000000;">The constraint is defined with the NOT FOR REPLICATION<br />
keywords.</td>
</tr>
<tr>
<td style="border:1px solid #000000;">CnstIsUpdateCascade</td>
<td style="border:1px solid #000000;" align="center">Constraint</td>
<td style="border:1px solid #000000;">A foreign key constraint with the ON UPDATE CASCADE<br />
option.</td>
</tr>
<tr>
<td style="border:1px solid #000000;">ExecIsAfterTrigger</td>
<td style="border:1px solid #000000;" align="center">Trigger</td>
<td style="border:1px solid #000000;">AFTER trigger.</td>
</tr>
<tr>
<td style="border:1px solid #000000;">ExecIsAnsiNullsOn</td>
<td style="border:1px solid #000000;" align="center">Procedure, Trigger, View</td>
<td style="border:1px solid #000000;">The setting of ANSI_NULLS at creation time.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">ExecIsDeleteTrigger</td>
<td style="border:1px solid #000000;" align="center">Trigger</td>
<td style="border:1px solid #000000;">DELETE trigger.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">ExecIsFirstDeleteTrigger</td>
<td style="border:1px solid #000000;" align="center">Trigger</td>
<td style="border:1px solid #000000;">The first trigger fired when a DELETE is executed against the<br />
table.</td>
</tr>
<tr>
<td style="border:1px solid #000000;">ExecIsFirstInsertTrigger</td>
<td style="border:1px solid #000000;" align="center">Trigger</td>
<td style="border:1px solid #000000;">The first trigger fired when an INSERT is executed against the<br />
table.</td>
</tr>
<tr>
<td style="border:1px solid #000000;">ExecIsFirstUpdateTrigger</td>
<td style="border:1px solid #000000;" align="center">Trigger</td>
<td style="border:1px solid #000000;">The first trigger fired when an UPDATE is executed against the<br />
table.</td>
</tr>
<tr>
<td style="border:1px solid #000000;">ExecIsInsertTrigger</td>
<td style="border:1px solid #000000;" align="center">Trigger</td>
<td style="border:1px solid #000000;">INSERT trigger.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">ExecIsInsteadOfTrigger</td>
<td style="border:1px solid #000000;" align="center">Trigger</td>
<td style="border:1px solid #000000;">INSTEAD OF trigger.</td>
</tr>
<tr>
<td style="border:1px solid #000000;">ExecIsLastDeleteTrigger</td>
<td style="border:1px solid #000000;" align="center">Trigger</td>
<td style="border:1px solid #000000;">The last trigger fired when a DELETE is executed against the<br />
table.</td>
</tr>
<tr>
<td style="border:1px solid #000000;">ExecIsLastInsertTrigger</td>
<td style="border:1px solid #000000;" align="center">Trigger</td>
<td style="border:1px solid #000000;">The last trigger fired when an INSERT is executed against the<br />
table.</td>
</tr>
<tr>
<td style="border:1px solid #000000;">ExecIsLastUpdateTrigger</td>
<td style="border:1px solid #000000;" align="center">Trigger</td>
<td style="border:1px solid #000000;">The last trigger fired when an UPDATE is executed against the<br />
table.</td>
</tr>
<tr>
<td style="border:1px solid #000000;">ExecIsQuotedIdentOn</td>
<td style="border:1px solid #000000;" align="center">Procedure, Trigger, View</td>
<td style="border:1px solid #000000;">The setting of QUOTED_IDENTIFIER at creation time.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">ExecIsStartup</td>
<td style="border:1px solid #000000;" align="center">Procedure</td>
<td style="border:1px solid #000000;">Startup procedure.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">ExecIsTriggerDisabled</td>
<td style="border:1px solid #000000;" align="center">Trigger</td>
<td style="border:1px solid #000000;">Disabled trigger.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">ExecIsUpdateTrigger</td>
<td style="border:1px solid #000000;" align="center">Trigger</td>
<td style="border:1px solid #000000;">UPDATE trigger.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">HasAfterTrigger</td>
<td style="border:1px solid #000000;" align="center">Table, View</td>
<td style="border:1px solid #000000;">Table or view has an AFTER trigger.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">HasInsertTrigger</td>
<td style="border:1px solid #000000;" align="center">Table, View</td>
<td style="border:1px solid #000000;">Table or view has an INSERT trigger.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">HasInsteadOfTrigger</td>
<td style="border:1px solid #000000;" align="center">Table, View</td>
<td style="border:1px solid #000000;">Table or view has an INSTEAD OF trigger.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">HasUpdateTrigger</td>
<td style="border:1px solid #000000;" align="center">Table, View</td>
<td style="border:1px solid #000000;">Table or view has an UPDATE trigger.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">IsAnsiNullsOn</td>
<td style="border:1px solid #000000;" align="center">Function, Procedure, Table, Trigger, View</td>
<td style="border:1px solid #000000;">Specifies that the ANSI NULLS option setting for the table is ON, meaning all comparisons against a null value evaluate to UNKNOWN. This setting applies to all expressions in the table definition, including computed columns and constraints, for as long as the table exists.  				1 = ON0 = OFF</td>
</tr>
<tr>
<td style="border:1px solid #000000;">IsCheckCnst</td>
<td style="border:1px solid #000000;" align="center">Any</td>
<td style="border:1px solid #000000;">CHECK constraint.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">IsConstraint</td>
<td style="border:1px solid #000000;" align="center">Any</td>
<td style="border:1px solid #000000;">Constraint.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">IsDefault</td>
<td style="border:1px solid #000000;" align="center">Any</td>
<td style="border:1px solid #000000;">Bound default.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">IsDefaultCnst</td>
<td style="border:1px solid #000000;" align="center">Any</td>
<td style="border:1px solid #000000;">DEFAULT constraint.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">IsDeterministic</td>
<td style="border:1px solid #000000;" align="center">Function, View</td>
<td style="border:1px solid #000000;">The determinism property of the function. Applies only to scalar- and table-valued functions.  				1 = Deterministic0 = Not DeterministicNULL = Not a scalar- or table-valued function, or invalid object ID.</td>
</tr>
<tr>
<td style="border:1px solid #000000;">IsExecuted</td>
<td style="border:1px solid #000000;" align="center">Any</td>
<td style="border:1px solid #000000;">Specifies how this object can be executed (view, procedure, or trigger).  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">IsExtendedProc</td>
<td style="border:1px solid #000000;" align="center">Any</td>
<td style="border:1px solid #000000;">Extended procedure.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">IsForeignKey</td>
<td style="border:1px solid #000000;" align="center">Any</td>
<td style="border:1px solid #000000;">FOREIGN KEY constraint.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">IsIndexed</td>
<td style="border:1px solid #000000;" align="center">Table, View</td>
<td style="border:1px solid #000000;">A table or view with an index.</td>
</tr>
<tr>
<td style="border:1px solid #000000;">IsIndexable</td>
<td style="border:1px solid #000000;" align="center">Table, View</td>
<td style="border:1px solid #000000;">A table or view on which an index may be created.</td>
</tr>
<tr>
<td style="border:1px solid #000000;">IsInlineFunction</td>
<td style="border:1px solid #000000;" align="center">Function</td>
<td style="border:1px solid #000000;">Inline function.  				1 = Inline function0 = Not inline functionNULL = Not a function, or invalid object ID.</td>
</tr>
<tr>
<td style="border:1px solid #000000;">IsMSShipped</td>
<td style="border:1px solid #000000;" align="center">Any</td>
<td style="border:1px solid #000000;">An object created during installation of Microsoft® SQL Server™ 2000.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">IsPrimaryKey</td>
<td style="border:1px solid #000000;" align="center">Any</td>
<td style="border:1px solid #000000;">PRIMARY KEY constraint.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">IsProcedure</td>
<td style="border:1px solid #000000;" align="center">Any</td>
<td style="border:1px solid #000000;">Procedure.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">IsQuotedIdentOn</td>
<td style="border:1px solid #000000;" align="center">Function, Procedure, Table, Trigger, View</td>
<td style="border:1px solid #000000;">Specifies that the quoted identifier setting for the table is ON, meaning double quotation marks delimit identifiers in all expressions involved in the table definition.  				1 = ON0 = OFF</td>
</tr>
<tr>
<td style="border:1px solid #000000;">IsReplProc</td>
<td style="border:1px solid #000000;" align="center">Any</td>
<td style="border:1px solid #000000;">Replication procedure.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">IsRule</td>
<td style="border:1px solid #000000;" align="center">Any</td>
<td style="border:1px solid #000000;">Bound rule.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">IsScalarFunction</td>
<td style="border:1px solid #000000;" align="center">Function</td>
<td style="border:1px solid #000000;">Scalar-valued function.  				1 = Scalar-valued0 = Table-valuedNULL = Not a function, or invalid object ID.</td>
</tr>
<tr>
<td style="border:1px solid #000000;">IsSchemaBound</td>
<td style="border:1px solid #000000;" align="center">Function, View</td>
<td style="border:1px solid #000000;">A schema bound function or view created with SCHEMABINDING.  				1 = Schema-bound0 = Not schema-boundNULL = Not a function or a view, or invalid object ID.</td>
</tr>
<tr>
<td style="border:1px solid #000000;">IsSystemTable</td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">System table.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">IsTable</td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">Table.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">IsTableFunction</td>
<td style="border:1px solid #000000;" align="center">Function</td>
<td style="border:1px solid #000000;">Table-valued function.  				1 = Table-valued0 = Scalar-valuedNULL = Not a function, or invalid object ID.</td>
</tr>
<tr>
<td style="border:1px solid #000000;">IsTrigger</td>
<td style="border:1px solid #000000;" align="center">Any</td>
<td style="border:1px solid #000000;">Trigger.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">IsUniqueCnst</td>
<td style="border:1px solid #000000;" align="center">Any</td>
<td style="border:1px solid #000000;">UNIQUE constraint.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">IsUserTable</td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">User-defined table.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">IsView</td>
<td style="border:1px solid #000000;" align="center">View</td>
<td style="border:1px solid #000000;">View.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">OwnerId</td>
<td style="border:1px solid #000000;" align="center">Any</td>
<td style="border:1px solid #000000;">Owner of the object.  				Nonnull = The database user ID of the object owner.NULL = Invalid input.</td>
</tr>
<tr>
<td style="border:1px solid #000000;">TableDeleteTrigger</td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">Table has a DELETE trigger.  				&gt;1 = ID of first trigger with given type.</td>
</tr>
<tr>
<td style="border:1px solid #000000;">TableDeleteTriggerCount</td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">The table has the specified number of DELETE triggers.  				&gt;1 = ID of first trigger with given type.NULL = Invalid input.</td>
</tr>
<tr>
<td style="border:1px solid #000000;"><span title="TableFullTextBackgroundUpdateIndexOn">TableFullTextBackground&#8230;</span></td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">The table has full-text background update index enabled.  				1 = TRUE0 = FALSE</td>
</tr>
<tr>
<td style="border:1px solid #000000;">TableFulltextCatalogId</td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">The ID of the full-text catalog in which the full-text index data for the table resides. Nonzero = Full-text catalog ID, associated with the unique index that<br />
identifies the rows in a full-text indexed table.0 = Table is not full-text indexed.</td>
</tr>
<tr>
<td style="border:1px solid #000000;"><span title="TableFullTextChangeTrackingOn">TableFullTextChangeTr&#8230;</span></td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">The table has full-text change-tracking enabled.  				1 = TRUE0 = FALSE</td>
</tr>
<tr>
<td style="border:1px solid #000000;">TableFulltextKeyColumn</td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">The ID of the column associated with the single-column unique index that is participating in the full-text index definition.  				0 = Table is not full-text indexed.</td>
</tr>
<tr>
<td style="border:1px solid #000000;"><span title="TableFullTextPopulateStatus">TableFullTextPopulate&#8230;</span></td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">0 = No population1 = Full population2 = Incremental population</td>
</tr>
<tr>
<td style="border:1px solid #000000;"><span title="TableHasActiveFulltextIndex">TableHasActiveFulltext&#8230;</span></td>
<td style="border:1px solid #000000;" align="center">Tables</td>
<td style="border:1px solid #000000;">The table has an active full-text index.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">TableHasCheckCnst</td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">The table has a CHECK constraint.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">TableHasClustIndex</td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">The table has a clustered index.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">TableHasDefaultCnst</td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">The table has a DEFAULT constraint.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">TableHasDeleteTrigger</td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">The table has a DELETE trigger.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">TableHasForeignKey</td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">The table has a FOREIGN KEY constraint.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">TableHasForeignRef</td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">Table is referenced by a FOREIGN KEY constraint.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">TableHasIdentity</td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">The table has an identity column.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">TableHasIndex</td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">The table has an index of any type.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">TableHasInsertTrigger</td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">The object has an Insert trigger.  				1 = True0 = FalseNULL = Invalid input.</td>
</tr>
<tr>
<td style="border:1px solid #000000;">TableHasNonclustIndex</td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">The table has a nonclustered index.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">TableHasPrimaryKey</td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">The table has a primary key.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">TableHasRowGuidCol</td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">The table has a ROWGUIDCOL for a uniqueidentifier column.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">TableHasTextImage</td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">The table has a text column.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">TableHasTimestamp</td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">The table has a timestamp column.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">TableHasUniqueCnst</td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">The table has a UNIQUE constraint.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">TableHasUpdateTrigger</td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">The object has an Update trigger.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">TableInsertTrigger</td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">The table has an INSERT trigger.  				&gt;1 = ID of first trigger with given type.</td>
</tr>
<tr>
<td style="border:1px solid #000000;">TableInsertTriggerCount</td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">The table has the specified number of INSERT triggers.  				&gt;1 = ID of first trigger with given type.</td>
</tr>
<tr>
<td style="border:1px solid #000000;">TableIsFake</td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">The table is not real. It is materialized internally on demand by SQL Server.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">TableIsPinned</td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">The table is pinned to be held in the data cache.  				1 = True0 = False</td>
</tr>
<tr>
<td style="border:1px solid #000000;">TableTextInRowLimit</td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">The maximum bytes allowed for text in row, or 0 if<br />
text in row option is not set.</td>
</tr>
<tr>
<td style="border:1px solid #000000;">TableUpdateTrigger</td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">The table has an UPDATE trigger.  				&gt;1 = ID of first trigger with given type.</td>
</tr>
<tr>
<td style="border:1px solid #000000;">TableUpdateTriggerCount</td>
<td style="border:1px solid #000000;" align="center">Table</td>
<td style="border:1px solid #000000;">The table has the specified number of UPDATE triggers.  				&gt;1 = ID of first trigger with given type.</td>
</tr>
</table>
<p>Nota: Tabela retirada do site <a href="http://msdn2.microsoft.com/en-us/library/ms176105.aspx" title="MSDN"><strong>MSDN</strong></a></p>
<p>A propriedade <strong>IsIndexable</strong> pode consumir significantes recursos de processamento.<br />
A propriedade <strong>TableHasActiveFulltextIndex</strong> retornará 1 (Verdadeiro) quando no mínimo uma coluna da tabela é adicionada com indíce.</p>
<p>Vamos aos exemplos:</p>
<p><strong>A. </strong>Para descobrir se um determinado objeto (Veiculo) é uma <strong>VIEW</strong>, basta executar a seguinte instrução</p>
<p>IF OBJECTPROPERTY(OBJECT_ID(&#8216;Veiculo&#8217;), &#8216;ISVIEW&#8217;) = 1<br />
PRINT &#8216;Veiculo é uma VIEW&#8217;<br />
ELSE<br />
PRINT &#8216;Veiculo não é uma VIEW&#8217;</p>
<p>Observe que utilizei a função <strong>OBJECT_ID</strong>, esta função retorna a identificação do objeto passado como parâmetro, que deve ser o nome do objeto na base de dados. Foi utilizado esta função para não haver a necessidade de descobrir a identificação do objeto.</p>
<p>Caso a necessidade seja outra, como por exemplo, saber se o objeto é uma tabela, basta substituir a palavra-chave <strong>ISVIEW </strong>por <strong>ISTABLE</strong>. Como no exemplo abaixo:</p>
<p>IF OBJECTPROPERTY(OBJECT_ID(&#8216;Veiculo&#8217;), &#8216;ISTABLE&#8217;) = 1<br />
PRINT &#8216;Veiculo é uma TABLE&#8217;<br />
ELSE<br />
PRINT &#8216;Veiculo não é uma TABLE&#8217;</p>
<p><strong>B.</strong> Saber se uma determinada tabela possui um campo do tipo <strong>TEXT</strong>, retornará 1 quando for verdadeiro e 0 quando for falso. Uma variável do tipo <a href="http://pt.wikipedia.org/wiki/Booleano" title="O que é Booleano?">booleana</a>.</p>
<p>SELECT OBJECTPROPERTY(OBJECT_ID(&#8216;Cliente&#8217;), &#8216;TableHasTextImage&#8217;)</p>
<p><strong>C. </strong>Saber se uma determinada tabela possui uma chave-primária</p>
<p>SELECT OBJECTPROPERTY(OBJECT_ID(&#8216;Fornecedor&#8217;), &#8216;TableHasPrimaryKey&#8217;)</p>
<p><strong>D. </strong>Saber se uma determinada tabela possui uma <strong><a href="http://pt.wikipedia.org/wiki/Triggers" title="O que é Trigger?">TRIGGER</a> SQL </strong>que remove (<strong>DELETE</strong>) registros</p>
<p>SELECT OBJECTPROPERTY(OBJECT_ID(&#8216;Cliente&#8217;), &#8216;TableDeleteTrigger&#8217;)</p>
<p><strong>E. </strong>Descobrir qual o proprietário de um determinado objeto, Ex.: <a href="http://pt.wikipedia.org/wiki/Procedure" title="O que é Procedure?"><strong>PROCEDURE</strong>, </a><strong>TRIGGER</strong>, <strong>TABLE</strong>, etc.</p>
<p>SELECT OBJECTPROPERTY(OBJECT_ID(&#8216;Veiculo&#8217;), &#8216;OwnerId&#8217;)</p>
<p>Esta função retorna a identificação do proprietário do objeto na base de dados ou <strong>NULL </strong>caso passado o parâmetro incorretamente.</p>
<p>Finalizo este artigo por aqui, deixe seu comentário, críticas e/ou sugestões.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sqlcomoumtodo.wordpress.com/31/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sqlcomoumtodo.wordpress.com/31/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlcomoumtodo.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlcomoumtodo.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlcomoumtodo.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlcomoumtodo.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlcomoumtodo.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlcomoumtodo.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlcomoumtodo.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlcomoumtodo.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlcomoumtodo.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlcomoumtodo.wordpress.com/31/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcomoumtodo.wordpress.com&blog=1803981&post=31&subd=sqlcomoumtodo&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://sqlcomoumtodo.wordpress.com/2007/11/07/como-saber-as-caracteristicas-de-um-objeto-em-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2f52b3927451451e9b8c69711aca639a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">alexandregavazza</media:title>
		</media:content>
	</item>
		<item>
		<title>A diferença entre DATALENGTH e LEN em SQL</title>
		<link>http://sqlcomoumtodo.wordpress.com/2007/11/01/a-diferenca-entre-datalength-e-len-em-sql/</link>
		<comments>http://sqlcomoumtodo.wordpress.com/2007/11/01/a-diferenca-entre-datalength-e-len-em-sql/#comments</comments>
		<pubDate>Thu, 01 Nov 2007 10:56:56 +0000</pubDate>
		<dc:creator>Alexandre Araujo</dc:creator>
				<category><![CDATA[Consulta]]></category>
		<category><![CDATA[DATALENGTH]]></category>
		<category><![CDATA[Funções]]></category>
		<category><![CDATA[LEN]]></category>
		<category><![CDATA[Programação]]></category>
		<category><![CDATA[SELECT]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Query]]></category>

		<guid isPermaLink="false">http://sqlcomoumtodo.wordpress.com/2007/11/01/a-diferenca-entre-datalength-e-len-em-sql/</guid>
		<description><![CDATA[A função DATALENGTH tem o objetivo retornar o número de bytes usados para representar uma determinada expressão. Esta função é geralmente utilizada em variáveis do tipo VARCHAR, VARBINARY, TEXT, IMAGE, NVARCHAR e NTEXT que são tipos de dados que podem armazenar grandes quantidades de dados.
Muitos confundem a função DATALENGTH com a função LEN, que são [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcomoumtodo.wordpress.com&blog=1803981&post=28&subd=sqlcomoumtodo&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>A função <strong>DATALENGTH </strong>tem o objetivo retornar o número de bytes usados para representar uma determinada expressão. Esta função é geralmente utilizada em variáveis do tipo <strong>VARCHAR</strong>, <strong>VARBINARY</strong>, <strong>TEXT</strong>, <strong>IMAGE</strong>, <strong>NVARCHAR </strong>e <strong>NTEXT</strong> que são tipos de dados que podem armazenar grandes quantidades de dados.</p>
<p>Muitos confundem a função <strong>DATALENGTH </strong>com a função <strong>LEN</strong>, que são totalmente diferentes, podendo retornar os mesmos valores. A função <strong>LEN </strong>tem como intuito retornar a quantidade de caracteres existentes em uma determinada expressão.</p>
<p>SELECT</p>
<blockquote><p>LEN(CPF) AS CPF</p></blockquote>
<p>FROM</p>
<blockquote><p>Cliente</p></blockquote>
<p>A instrução acima mostrará a quantidade de caracteres existentes no campo &#8216;CPF&#8217; da tabela &#8216;Cliente&#8217;.</p>
<p>SELECT</p>
<blockquote><p>DATALENGTH(CPF) AS CPF</p></blockquote>
<p>FROM</p>
<blockquote><p>Cliente</p></blockquote>
<p>Já esta outra consulta informa o número de bytes que o campo de um determinado registro está ocupando na base de dados. Quando o campo é <strong>NULL</strong>, ou seja, nulo em português, significa que o campo não tem valor nenhum e o retorno da função <strong>DATALENGTH </strong>é nulo enquanto o retorno da função <strong>LEN </strong>é 0, indicando que não possue nenhum caracter na expressão.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sqlcomoumtodo.wordpress.com/28/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sqlcomoumtodo.wordpress.com/28/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlcomoumtodo.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlcomoumtodo.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlcomoumtodo.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlcomoumtodo.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlcomoumtodo.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlcomoumtodo.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlcomoumtodo.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlcomoumtodo.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlcomoumtodo.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlcomoumtodo.wordpress.com/28/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcomoumtodo.wordpress.com&blog=1803981&post=28&subd=sqlcomoumtodo&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://sqlcomoumtodo.wordpress.com/2007/11/01/a-diferenca-entre-datalength-e-len-em-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2f52b3927451451e9b8c69711aca639a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">alexandregavazza</media:title>
		</media:content>
	</item>
		<item>
		<title>Identificando usuários em SQL</title>
		<link>http://sqlcomoumtodo.wordpress.com/2007/10/31/identificando-usuarios-em-sql/</link>
		<comments>http://sqlcomoumtodo.wordpress.com/2007/10/31/identificando-usuarios-em-sql/#comments</comments>
		<pubDate>Wed, 31 Oct 2007 10:48:43 +0000</pubDate>
		<dc:creator>Alexandre Araujo</dc:creator>
				<category><![CDATA[Consulta]]></category>
		<category><![CDATA[Programação]]></category>
		<category><![CDATA[Query]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[USER_NAME]]></category>
		<category><![CDATA[sysusers]]></category>

		<guid isPermaLink="false">http://sqlcomoumtodo.wordpress.com/2007/10/31/identificando-usuarios-em-sql/</guid>
		<description><![CDATA[A palavra chave USER_NAME no SQL é usada para informar o nome do usuário (como o próprio nome diz). Veja o exemplo abaixo:
SELECT USER_NAME()
No caso acima informará o usuário que está logado na base de dados, se o usuário estiver em rede será informado o nome da rede, barra invertida e em seguida o nome [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcomoumtodo.wordpress.com&blog=1803981&post=27&subd=sqlcomoumtodo&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>A palavra chave <strong>USER_NAME</strong> no <strong>SQL </strong>é usada para informar o nome do usuário (como o próprio nome diz). Veja o exemplo abaixo:</p>
<p>SELECT USER_NAME()</p>
<p>No caso acima informará o usuário que está logado na base de dados, se o usuário estiver em rede será informado o nome da rede, barra invertida e em seguida o nome do usuário. Ex.: &#8216;SQLCOMOUMTODO\alexandre&#8217;.</p>
<p>O <strong>USER_NAME</strong> pode receber um parâmetro que deve ser o ID do usuário na base de dados.</p>
<p>SELECT USER_NAME(1)</p>
<p>Na maioria dos casos, o ID 1 corresponde ao usuário &#8216;dbo&#8217;.</p>
<p>Para se obter maiores informações sobre o usuário, deve fazer o filtro na tabela de gerenciamento de usuários, a &#8217;sysusers&#8217;. Esta tabela pode fornecer informações como: quando foi criado o usuário (createdate), quando foi atualizado o usuário (updatedate), se o usuário está logado no momento, entre outras informações.</p>
<p>SELECT</p>
<blockquote><p>*</p></blockquote>
<p>FROM</p>
<blockquote><p>sysusers</p></blockquote>
<p>WHERE</p>
<blockquote><p>name = USER_NAME(1)</p></blockquote>
<p>A instrução acima retorna a mesma informação da instrução abaixo. Apenas mudando os campos que são comparados.</p>
<p>SELECT</p>
<blockquote><p>*</p></blockquote>
<p>FROM</p>
<blockquote><p>sysusers</p></blockquote>
<p>WHERE</p>
<blockquote><p>uid = 1</p></blockquote>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sqlcomoumtodo.wordpress.com/27/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sqlcomoumtodo.wordpress.com/27/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sqlcomoumtodo.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sqlcomoumtodo.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sqlcomoumtodo.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sqlcomoumtodo.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sqlcomoumtodo.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sqlcomoumtodo.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sqlcomoumtodo.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sqlcomoumtodo.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sqlcomoumtodo.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sqlcomoumtodo.wordpress.com/27/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sqlcomoumtodo.wordpress.com&blog=1803981&post=27&subd=sqlcomoumtodo&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://sqlcomoumtodo.wordpress.com/2007/10/31/identificando-usuarios-em-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2f52b3927451451e9b8c69711aca639a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">alexandregavazza</media:title>
		</media:content>
	</item>
	</channel>
</rss>