<?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</title>
	<atom:link href="http://cubicthoughts.com/category/sql/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>Guest Lecture @ RMIT School of Business</title>
		<link>http://cubicthoughts.com/2009/12/13/guest-lecture/</link>
		<comments>http://cubicthoughts.com/2009/12/13/guest-lecture/#comments</comments>
		<pubDate>Sun, 13 Dec 2009 06:28:24 +0000</pubDate>
		<dc:creator>Deepak Vasa</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[lecture]]></category>
		<category><![CDATA[RDBMS]]></category>
		<category><![CDATA[RMIT]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[TeamBoard]]></category>

		<guid isPermaLink="false">http://cubicthoughts.com/?p=147</guid>
		<description><![CDATA[I did a Guest Lecture on how we use RDBMS (SQL Server) at my work. It was aimed at first year undergrads who are doing an introduction to Relational Databases (RBDMS). I had some great time in preparing the presentation slides and delivering the content. The students were quite good and were keen to understand [...]]]></description>
			<content:encoded><![CDATA[<p>I did a Guest Lecture on how we use RDBMS (SQL Server) at my work. It was aimed at first year undergrads who are doing an introduction to Relational Databases (RBDMS). I had some great time in preparing the presentation slides and delivering the content. The students were quite good and were keen to understand how databases are used in Industry. My whole lecture was focused on how we do a new database project at work right from inception phase, design phase to finally incorporating it into the whole project. </p>
<p>The best part is they loved the fact that we use a White-board to do all our design and planning work, which we later capture by taking photos. With the new <a href="http://www.teamboard.com/">TeamBoard</a> system that we got recently it&#8217;s got even more fun. <img src='http://cubicthoughts.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I concluded at the end of the lecture that all the social networks that they interact with all have massive databases behind the scenes. So in future when they are involved in designing databases, depending on the project, they can use their extensive end user experience and think of the various information that they will need to store in the database. </p>
Written by Deepak Vasa - <a href="http://www.cubicthoughts.com">Visit Website</a>]]></content:encoded>
			<wfw:commentRss>http://cubicthoughts.com/2009/12/13/guest-lecture/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>
		<item>
		<title>LINQ query to get all the column names in the DBML tables</title>
		<link>http://cubicthoughts.com/2008/10/31/linq-query-to-get-all-the-column-names-in-the-dbml-tables/</link>
		<comments>http://cubicthoughts.com/2008/10/31/linq-query-to-get-all-the-column-names-in-the-dbml-tables/#comments</comments>
		<pubDate>Fri, 31 Oct 2008 05:51:00 +0000</pubDate>
		<dc:creator>Deepak Vasa</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Column Names]]></category>
		<category><![CDATA[DBML]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[Row Names]]></category>
		<category><![CDATA[Table Names]]></category>

		<guid isPermaLink="false">http://cubicthoughts.com/?p=90</guid>
		<description><![CDATA[// LINQ query to get all the column names for every Table var model = new AttributeMappingSource().GetModel(typeof(ReportDBMLClassesDataContext)); int i = 0; ArrayList lblList = new ArrayList(); foreach (var mt in model.GetTables()) { i++; Label lbl = new Label(); lbl.Text = mt.TableName.ToString(); lbl.ID = &#8220;lbl&#8221; + i; Panel1.Controls.Add(lbl); Panel1.Controls.Add(new LiteralControl(&#8220;&#60;br&#62;&#8221;)); int r = 0; foreach (var [...]]]></description>
			<content:encoded><![CDATA[<p>// LINQ query to get all the column names for every Table<br />
var model = new AttributeMappingSource().GetModel(typeof(ReportDBMLClassesDataContext));<br />
int i = 0;<br />
ArrayList lblList = new ArrayList();<br />
foreach (var mt in model.GetTables())<br />
{<br />
i++;<br />
Label lbl = new Label();<br />
lbl.Text = mt.TableName.ToString();<br />
lbl.ID = &#8220;lbl&#8221; + i;<br />
Panel1.Controls.Add(lbl);<br />
Panel1.Controls.Add(new LiteralControl(&#8220;&lt;br&gt;&#8221;));<br />
int r = 0;<br />
foreach (var dm in mt.RowType.DataMembers)<br />
{<br />
r++;<br />
Label rlbl = new Label();<br />
rlbl.Text = dm.MappedName.ToString();<br />
rlbl.ID = &#8220;rlbl&#8221; + i + &#8220;&#8221; + r;<br />
Panel1.Controls.Add(rlbl);<br />
Panel1.Controls.Add(new LiteralControl(&#8220;&lt;br&gt;&#8221;));<br />
}<br />
}</p>
Written by Deepak Vasa - <a href="http://www.cubicthoughts.com">Visit Website</a>]]></content:encoded>
			<wfw:commentRss>http://cubicthoughts.com/2008/10/31/linq-query-to-get-all-the-column-names-in-the-dbml-tables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server 2008 &#8211; my thoughts&#8230;.</title>
		<link>http://cubicthoughts.com/2008/08/12/sql-server-2008-my-thoughts/</link>
		<comments>http://cubicthoughts.com/2008/08/12/sql-server-2008-my-thoughts/#comments</comments>
		<pubDate>Tue, 12 Aug 2008 13:30:55 +0000</pubDate>
		<dc:creator>Deepak Vasa</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[FileStreaming]]></category>
		<category><![CDATA[Filtered Indexing]]></category>
		<category><![CDATA[Merge Statements]]></category>
		<category><![CDATA[New Features]]></category>
		<category><![CDATA[Sparse columns]]></category>
		<category><![CDATA[SQL Server 2008]]></category>

		<guid isPermaLink="false">http://cubicthoughts.com/?p=60</guid>
		<description><![CDATA[I have been reading about SQL Server 2008 for a while and today I got a glimpse of the various features and how it can help developers at the Victoria Dot Net users group meeting. Thanks to the special presentation by Chris Hewitt &#8211; &#8220;What should developers know about SQL Server 2008?&#8221; A few days [...]]]></description>
			<content:encoded><![CDATA[<p>I have been reading about SQL Server 2008 for a while and today I got a glimpse of the various features and how it can help developers at the <a href="http://www.victoriadotnet.com.au" target="_blank">Victoria Dot Net</a> users group meeting. Thanks to the special presentation by <a href="http://endintiers.com/default.aspx" target="_blank">Chris Hewitt</a> &#8211; &#8220;What should developers know about SQL Server 2008?&#8221;</p>
<p>A few days ago, I read about the new &#8220;<strong>File Stream</strong>&#8221; data type and my initial thoughts were how would I use this new feature and where would this be more usefull, later I realised that I could use the FileStreaming data type to store all the various CSV reports that I generate from our various applications. So effectively instead of storing it on a file server and putting in the reference in SQL, I could easily store the entire CSV file in to SQL Server and let it worry about where and how it stores it. More over I can also have all the report metadata in one location (sweet <img src='http://cubicthoughts.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>In the presentation Chris showed us a few examples on how we can send a <strong>Table as parameter</strong> to Stored Procedures and the new Merge Statement.  Well, frankly speaking it took me a few seconds to comprehend the huge benifits of sending in a table as a parameter to a stored procedure. The biggest benifit is the ability to insert large number of rows in one go by passing the data as a table parameter. Previously you could do that with temp tables but those tables were only specific to the stored procedure which creates them, however with this new feature we have some thing on the lines of Global Temp Tables. For more detailed explanation and examples, please refer this <a title="Passing table as parameter in stored procedures" href="http://searchsqlserver.techtarget.com/tip/0,289483,sid87_gci1280004,00.html" target="_blank">article</a></p>
<p>Coming to the <strong>Merge statement</strong> that&#8217;s another cool feature that has huge number of benefits. In scenarios where you need to to insert, update, or delete data based on certain conditions, programmers have to take care of the actions in the application, however with Merge statements we can do the insert, update or delete in one single statement based on the join conditions. For more information, please refer this article at <a title="Merge Statement in Sql Server 2008" href="http://www.builderau.com.au/program/sqlserver/soa/Using-SQL-Server-2008-s-MERGE-statement/0,339028455,339283059,00.htm" target="_blank">BuilderAU</a>.</p>
<p>Another cool feature is the <strong>Filtered Indexing</strong>. As the name suggests, all it means is that when we create Indexes for a table in SQL Server 2008 based on a particular criteria (simple where clause). I am very keen to test this on one our biggest tables (9 million rows and counting). At the moment  it takes quite a bit of time to query this table for certain criteria, I would love to do some bench marking on this table and see how efficient the Filtered Indexes are.</p>
<p>Finally a one more interesting feature is the ability to Debug Sql Statements in the same way as .NET code. Chris showed how we could debug any SQL statement or Stored procedure, and also the MS has finally introduced Intellisense for SQL statements. Allthough I have been told that 3rd party tools have been providing SQL intellisense for quite some time now.</p>
<p>For those of you who are interested in other features like Sparse, new DateTime formats, new Convert functionality etc, please refer <a href="http://www.microsoft.com/sqlserver/2008/en/us/overview.aspx">SQL Server 2008 @ Microsoft</a>.</p>
Written by Deepak Vasa - <a href="http://www.cubicthoughts.com">Visit Website</a>]]></content:encoded>
			<wfw:commentRss>http://cubicthoughts.com/2008/08/12/sql-server-2008-my-thoughts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to convert ntext to nvarchar(max) in SQL 2005 &#8211; the right way</title>
		<link>http://cubicthoughts.com/2008/08/05/how-to-convert-ntext-to-nvarcharmax-in-sql-2005-the-right-way/</link>
		<comments>http://cubicthoughts.com/2008/08/05/how-to-convert-ntext-to-nvarcharmax-in-sql-2005-the-right-way/#comments</comments>
		<pubDate>Tue, 05 Aug 2008 01:54:04 +0000</pubDate>
		<dc:creator>Deepak Vasa</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[ntext]]></category>
		<category><![CDATA[nvarchar(max)]]></category>
		<category><![CDATA[Sql Server 2005]]></category>

		<guid isPermaLink="false">http://cubicthoughts.com/?p=55</guid>
		<description><![CDATA[Today, I found this very very useful blog on how to convert ntext fields to nvarchar(max) in Sql 2005. Apparently when converting a field from ntext to nvarchar(max), SQL Server does not change the internal structure and this is bad as the performance slows down significantly. However the following blog has got a simple fix [...]]]></description>
			<content:encoded><![CDATA[<p>Today, I found this very very useful blog on how to convert ntext fields to nvarchar(max) in Sql 2005. Apparently when converting a field from ntext to nvarchar(max), SQL Server does not change the internal structure and this is bad as the performance slows down significantly. However the following blog has got a simple fix to make SQL do the correct change.</p>
<p><a title="ntext vs nvarchar(max) in Sql Server 2005" href="http://geekswithblogs.net/johnsPerfBlog/archive/2008/04/16/ntext-vs-nvarcharmax-in-sql-2005.aspx" target="_blank">http://geekswithblogs.net/johnsPerfBlog/archive/2008/04/16/ntext-vs-nvarcharmax-in-sql-2005.aspx</a></p>
Written by Deepak Vasa - <a href="http://www.cubicthoughts.com">Visit Website</a>]]></content:encoded>
			<wfw:commentRss>http://cubicthoughts.com/2008/08/05/how-to-convert-ntext-to-nvarcharmax-in-sql-2005-the-right-way/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Six steps to secure sensitive  data in MySQL</title>
		<link>http://cubicthoughts.com/2006/08/09/six-steps-to-secure-sensitive-data-in-mysql/</link>
		<comments>http://cubicthoughts.com/2006/08/09/six-steps-to-secure-sensitive-data-in-mysql/#comments</comments>
		<pubDate>Wed, 09 Aug 2006 02:04:01 +0000</pubDate>
		<dc:creator>Deepak Vasa</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[Usefull Links]]></category>

		<guid isPermaLink="false">http://www.cubicthoughts.com/?p=35</guid>
		<description><![CDATA[I found this interesting article on Builder Au the other day. If you are using MySQL extensively then it&#8217;s an article worth reading. Six Steps to secure sensitive data in MySql Written by Deepak Vasa - Visit Website]]></description>
			<content:encoded><![CDATA[<p>I found this interesting article on Builder Au the other day. If you are using MySQL extensively then it&#8217;s an article worth reading.<br />
<a title="Six steps to secure sensitive data in MySql" href="http://www.builderau.com.au/program/mysql/soa/Six_steps_to_secure_sensitive_data_in_MySQL/0,39028784,39266102,00.htm">Six Steps to secure sensitive data in MySql</a></p>
Written by Deepak Vasa - <a href="http://www.cubicthoughts.com">Visit Website</a>]]></content:encoded>
			<wfw:commentRss>http://cubicthoughts.com/2006/08/09/six-steps-to-secure-sensitive-data-in-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flattening Out Data with One of the Coolest SQL Tricks Ever</title>
		<link>http://cubicthoughts.com/2006/06/07/flattening-out-data-with-one-of-the-coolest-sql-tricks-ever/</link>
		<comments>http://cubicthoughts.com/2006/06/07/flattening-out-data-with-one-of-the-coolest-sql-tricks-ever/#comments</comments>
		<pubDate>Wed, 07 Jun 2006 00:14:02 +0000</pubDate>
		<dc:creator>Deepak Vasa</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[Usefull Links]]></category>

		<guid isPermaLink="false">http://www.cubicthoughts.com/?p=7</guid>
		<description><![CDATA[Recently, I was wondering if would be able to join multiple rows returned from a select query in to a single csv row. To my surprise, I did find a solution, it’s very simple and I really find it cool. For all those SQL junkies..there check this link out. Flattening Out Data with One of [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I was wondering if would be able to join multiple rows returned from a select query in to a single csv row. To my surprise, I did find a solution, it’s very simple and I really find it cool. For all those SQL junkies..there check this link out.</p>
<p><a href="http://ryanfarley.com/blog/archive/2005/02/17/1712.aspx">Flattening Out Data with One of the Coolest SQL Tricks Ever</a></p>
Written by Deepak Vasa - <a href="http://www.cubicthoughts.com">Visit Website</a>]]></content:encoded>
			<wfw:commentRss>http://cubicthoughts.com/2006/06/07/flattening-out-data-with-one-of-the-coolest-sql-tricks-ever/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

