<?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/"
	>

<channel>
	<title>D-Blog &#187; Sql Tricks</title>
	<atom:link href="http://cubicthoughts.com/tag/sql-tricks/feed/" rel="self" type="application/rss+xml" />
	<link>http://cubicthoughts.com</link>
	<description>just about anything...</description>
	<lastBuildDate>Tue, 29 Nov 2011 23:48:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Using the field name alias in SQL Where clause</title>
		<link>http://cubicthoughts.com/2009/03/17/using-the-field-name-alias-in-sql-where-clause/</link>
		<comments>http://cubicthoughts.com/2009/03/17/using-the-field-name-alias-in-sql-where-clause/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 23:39:29 +0000</pubDate>
		<dc:creator>Deepak Vasa</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[Column Alias]]></category>
		<category><![CDATA[SELECT statement]]></category>
		<category><![CDATA[Sql Server 2005]]></category>
		<category><![CDATA[Sql Tricks]]></category>
		<category><![CDATA[WHERE clause]]></category>

		<guid isPermaLink="false">http://cubicthoughts.com/?p=119</guid>
		<description><![CDATA[Often I encounter SQL queries where I would love to use the alias names of my columns in the WHERE clause, today while trawling around the web I found a cool and easy way to do it. Here&#8217;s an example: WITH Customer_Info AS ( SELECT (Surname + &#8216;, &#8216; + Firstname) AS FullName, (Address_Line_1 + [...]]]></description>
			<content:encoded><![CDATA[<p>Often I encounter SQL queries where I would love to use the alias names of my columns in the WHERE clause, today while trawling around the web I found a cool and easy way to do it. Here&#8217;s an example:</p>
<p>WITH Customer_Info AS<br />
(<br />
    SELECT (Surname + &#8216;, &#8216; + Firstname) AS FullName,<br />
    (Address_Line_1 + &#8216;,&#8217; + Address_Line_2) AS Customer_Address<br />
    FROM Customers<br />
)<br />
SELECT FullName, Customer_Address<br />
FROM Customer_Info<br />
WHERE FullName LIKE &#8216;Smith%&#8217;</p>
Written by Deepak Vasa - <a href="http://www.cubicthoughts.com">Visit Website</a>]]></content:encoded>
			<wfw:commentRss>http://cubicthoughts.com/2009/03/17/using-the-field-name-alias-in-sql-where-clause/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Query to get the column names/types for all tables in SQL 2005</title>
		<link>http://cubicthoughts.com/2009/02/11/query-to-get-the-column-namestypes-for-all-tables-in-sql-2005/</link>
		<comments>http://cubicthoughts.com/2009/02/11/query-to-get-the-column-namestypes-for-all-tables-in-sql-2005/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 22:57:10 +0000</pubDate>
		<dc:creator>Deepak Vasa</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[Sql Server 2005]]></category>
		<category><![CDATA[Sql Tricks]]></category>

		<guid isPermaLink="false">http://cubicthoughts.com/?p=106</guid>
		<description><![CDATA[SELECT schemas.name AS [Schema], tables.name AS [Table], columns.name AS [Column], CASE WHEN columns.system_type_id = 34 THEN &#8216;byte[]&#8216; WHEN columns.system_type_id = 35 THEN &#8216;string&#8217; WHEN columns.system_type_id = 36 THEN &#8216;System.Guid&#8217; WHEN columns.system_type_id = 48 THEN &#8216;byte&#8217; WHEN columns.system_type_id = 52 THEN &#8216;short&#8217; WHEN columns.system_type_id = 56 THEN &#8216;int&#8217; WHEN columns.system_type_id = 58 THEN &#8216;System.DateTime&#8217; WHEN columns.system_type_id [...]]]></description>
			<content:encoded><![CDATA[<p>SELECT schemas.name AS [Schema],<br />
tables.name AS [Table],<br />
columns.name AS [Column],<br />
CASE<br />
WHEN columns.system_type_id = 34 THEN &#8216;byte[]&#8216;<br />
WHEN columns.system_type_id = 35 THEN &#8216;string&#8217;<br />
WHEN columns.system_type_id = 36 THEN &#8216;System.Guid&#8217;<br />
WHEN columns.system_type_id = 48 THEN &#8216;byte&#8217;<br />
WHEN columns.system_type_id = 52 THEN &#8216;short&#8217;<br />
WHEN columns.system_type_id = 56 THEN &#8216;int&#8217;<br />
WHEN columns.system_type_id = 58 THEN &#8216;System.DateTime&#8217;<br />
WHEN columns.system_type_id = 59 THEN &#8216;float&#8217;<br />
WHEN columns.system_type_id = 60 THEN &#8216;decimal&#8217;<br />
WHEN columns.system_type_id = 61 THEN &#8216;System.DateTime&#8217;<br />
WHEN columns.system_type_id = 62 THEN &#8216;double&#8217;<br />
WHEN columns.system_type_id = 98 THEN &#8216;object&#8217;<br />
WHEN columns.system_type_id = 99 THEN &#8216;string&#8217;<br />
WHEN columns.system_type_id = 104 THEN &#8216;bool&#8217;<br />
WHEN columns.system_type_id = 106 THEN &#8216;decimal&#8217;<br />
WHEN columns.system_type_id = 108 THEN &#8216;decimal&#8217;<br />
WHEN columns.system_type_id = 122 THEN &#8216;decimal&#8217;<br />
WHEN columns.system_type_id = 127 THEN &#8216;long&#8217;<br />
WHEN columns.system_type_id = 165 THEN &#8216;byte[]&#8216;<br />
WHEN columns.system_type_id = 167 THEN &#8216;string&#8217;<br />
WHEN columns.system_type_id = 173 THEN &#8216;byte[]&#8216;<br />
WHEN columns.system_type_id = 175 THEN &#8216;string&#8217;<br />
WHEN columns.system_type_id = 189 THEN &#8216;long&#8217;<br />
WHEN columns.system_type_id = 231 THEN &#8216;string&#8217;<br />
WHEN columns.system_type_id = 239 THEN &#8216;string&#8217;<br />
WHEN columns.system_type_id = 241 THEN &#8216;string&#8217;<br />
WHEN columns.system_type_id = 241 THEN &#8216;string&#8217;<br />
END AS [Type],<br />
columns.is_nullable AS [Nullable]</p>
<p>FROM sys.tables tables<br />
INNER JOIN sys.schemas schemas ON (tables.schema_id = schemas.schema_id )<br />
INNER JOIN sys.columns columns ON (columns.object_id = tables.object_id)</p>
<p>WHERE tables.name <> &#8216;sysdiagrams&#8217;<br />
AND tables.name <> &#8216;dtproperties&#8217;</p>
<p>ORDER BY [Schema], [Table], [Column], [Type]</p>
Written by Deepak Vasa - <a href="http://www.cubicthoughts.com">Visit Website</a>]]></content:encoded>
			<wfw:commentRss>http://cubicthoughts.com/2009/02/11/query-to-get-the-column-namestypes-for-all-tables-in-sql-2005/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

