<?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>QBurst Technologies - Blog &#187; case-sensitivity</title>
	<atom:link href="http://www.qburst.com/blog/tag/case-sensitivity/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.qburst.com/blog</link>
	<description></description>
	<lastBuildDate>Thu, 19 Jan 2012 13:50:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Collation in SQL</title>
		<link>http://www.qburst.com/blog/2009/06/collation-in-sql/</link>
		<comments>http://www.qburst.com/blog/2009/06/collation-in-sql/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 05:48:19 +0000</pubDate>
		<dc:creator>Pradeep Iyer</dc:creator>
				<category><![CDATA[Career]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[case-sensitivity]]></category>
		<category><![CDATA[collation]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.qburst.com/blog/?p=304</guid>
		<description><![CDATA[<p><strong>Collation</strong> defines how data is sorted and compared in SQL.  It is a set of rules that defines case-sensitivity, accent sensitivity, width-sensitivity etc.  The most common use of collation is in case-sensitive search using SQL query. Let&#8217;s see how it proves to be useful with case-sensitivity.</p>
<p>Normally, it is impossible to perform a case-sensitive search in SQL. For example, see the following queries:</p>
<p><span style="color: #0000ff;">SELECT </span>* <span style="color: #0000ff;">FROM</span> myTable <span style="color: #0000ff;">WHERE</span> myCompany=&#8217;QBurst&#8217;</p>
<p><span style="color: #0000ff;">SELECT</span> * <span style="color: #0000ff;">FROM</span> myTable <span style="color: #0000ff;">WHERE</span> myCompany=&#8217;qburst&#8217;</p>
<p>Both queries will produce the same result when they are executed.  But there are lots of cases where we want to differentiate the result based on search string case.</p>
<p>The necessity for this type of search...</p>]]></description>
			<content:encoded><![CDATA[<p><strong>Collation</strong> defines how data is sorted and compared in SQL.  It is a set of rules that defines case-sensitivity, accent sensitivity, width-sensitivity etc.  The most common use of collation is in case-sensitive search using SQL query. Let&#8217;s see how it proves to be useful with case-sensitivity.</p>
<p>Normally, it is impossible to perform a case-sensitive search in SQL. For example, see the following queries:</p>
<p><span style="color: #0000ff;">SELECT </span>* <span style="color: #0000ff;">FROM</span> myTable <span style="color: #0000ff;">WHERE</span> myCompany=&#8217;QBurst&#8217;</p>
<p><span style="color: #0000ff;">SELECT</span> * <span style="color: #0000ff;">FROM</span> myTable <span style="color: #0000ff;">WHERE</span> myCompany=&#8217;qburst&#8217;</p>
<p>Both queries will produce the same result when they are executed.  But there are lots of cases where we want to differentiate the result based on search string case.</p>
<p>The necessity for this type of search has greatly increased,  so Microsoft introduced a feature known as &#8220;Collation&#8221;. With collation, we can redefine the search scenario at the database level (rewriting the default collation of SQL server set during its installation).  For the previous example, if we want to get results for &#8220;QBurst&#8221; only if we search with string &#8220;QBurst&#8221; and with no other case combination, we should write the query like:</p>
<p><span style="color: #0000ff;">SELECT</span> * <span style="color: #0000ff;">FROM</span> myTable <span style="color: #0000ff;">WHERE</span> myCompany=&#8217;QBurst&#8217; <span style="color: #0000ff;">COLLATE</span> SQL_Latin1_General_Cp437_CS_AS</p>
<p>Here the only thing you may not be familiar with will be &#8220;SQL_Latin1_General_Cp437_CS_AS &#8220;.  This string is called Collation Name.  Microsoft defines different combinations of collation names, with the combinations produced by using various supporting languages for accent-sensitivity and also with case-sensitive/case-insensitive options. You can have a detailed look on more collation names here:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms144250(SQL.90).aspx">http://msdn.microsoft.com/en-us/library/ms144250(SQL.90).aspx</a></p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms180175.aspx">http://msdn.microsoft.com/en-us/library/ms180175.aspx</a></p>
<p>The collation can also be applied in the parent levels such as when creating databases.  The statement, <strong>&#8220;<span style="color: #0000ff;">CREATE</span> <span style="color: #0000ff;">DATABASE</span> myCollationDatabase <span style="color: #0000ff;">COLLATE</span> Latin1_General_Cp437_CS_AS&#8221;</strong>, makes the whole database arranged according to the collation specified.</p>
<p>The same can also be extended to applying different collations for different columns in a table. The code below shows an example:</p>
<p><span style="color: #0000ff;">CREATE</span> <span style="color: #0000ff;">TABLE</span> myCollationTable</p>
<p>{</p>
<p>userName <span style="color: #0000ff;">VARCHAR</span>(20) <span style="color: #0000ff;">COLLATE</span> SQL_Latin1_General_Cp437_CI_AI,</p>
<p>userOccupation <span style="color: #0000ff;">VARCHAR</span>(30) <span style="color: #0000ff;">COLLATE</span> SQL_Latin1_General_Cp1_CI_AI,</p>
<p>userCompany <span style="color: #0000ff;">VARCHAR</span>(30) <span style="color: #0000ff;">COLLATE</span> SQL_Latin1_General_Cp1_CS_AS</p>
<p>}</p>
<p>Collation can be very efficient if used in a proper way. No major limitations have been reported yet for this feature. Now, you can try it for yourself.</p>
<p>Happy coding!</p>
<div style="padding-top:5px;padding-right:0px;padding-bottom:5px;padding-left:0px;;">
											<iframe
												style="height:25px !important; border:0px solid gray !important; overflow:hidden !important; width:550px !important;" frameborder="0" scrolling="no" allowTransparency="true"
												src="http://www.linksalpha.com/social?blog=QBurst+Technologies+-+Blog&link=http%3A%2F%2Fwww.qburst.com%2Fblog%2F2009%2F06%2Fcollation-in-sql%2F&title=Collation+in+SQL&desc=Collation+defines+how+data+is+sorted+and+compared+in+SQL.%C2%A0+It+is+a+set+of+rules+that+defines+case-sensitivity%2C+accent+sensitivity%2C+width-sensitivity+etc.%C2%A0+The+most+common+use+of+collation+is+in+case&fc=333333&fs=arial&fblname=like&fblref=facebook&fbllang=en_US&fblshow=1&fbsbutton=1&fbsctr=1&fbslang=en&fbsendbutton=0&twbutton=1&twlang=en&twmention=&twrelated1=&twrelated2=&twctr=1&lnkdshow=noshow&lnkdctr=1&buzzbutton=1&buzzlang=en&buzzctr=1&diggbutton=0&diggctr=0&stblbutton=1&stblctr=1&g1button=1&g1ctr=1&g1lang=en-US">
											</iframe>
										</div>]]></content:encoded>
			<wfw:commentRss>http://www.qburst.com/blog/2009/06/collation-in-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

