<?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>techtamasha.com &#187; SQL</title>
	<atom:link href="http://www.techtamasha.com/category/sql/feed" rel="self" type="application/rss+xml" />
	<link>http://www.techtamasha.com</link>
	<description>a new play everyday</description>
	<lastBuildDate>Sat, 22 May 2010 11:49:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Wildcards(&#8220;_&#8221; and &#8220;%&#8221;) in SQL</title>
		<link>http://www.techtamasha.com/wildcards_-and-in-sql/24</link>
		<comments>http://www.techtamasha.com/wildcards_-and-in-sql/24#comments</comments>
		<pubDate>Thu, 17 Jan 2008 05:36:24 +0000</pubDate>
		<dc:creator>Nischal Shetty</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://techtamasha.com/?p=24</guid>
		<description><![CDATA[We can use the WILDCARDS &#8220;_&#8221; and &#8220;%&#8221; in our SQL queries be it MS SQL or My SQl as follows: Wildcard underscore &#8220;_&#8221; : &#8220;_&#8221; helps to match exactly one character. Ex. select name from name_table where name like &#8220;c_p&#8221; The above query will return words such as &#8220;cap&#8221;, &#8220;cop&#8221;, &#8220;cup&#8221; or basically anything [...]]]></description>
			<content:encoded><![CDATA[<p>We can use the WILDCARDS &#8220;_&#8221; and &#8220;%&#8221; in our SQL queries be it MS SQL or My SQl as follows:</p>
<p>Wildcard underscore &#8220;_&#8221; :</p>
<p>&#8220;_&#8221; helps to match exactly one character.</p>
<p>Ex. select name from name_table where name like &#8220;c_p&#8221;</p>
<p>The above query will return words such as &#8220;cap&#8221;, &#8220;cop&#8221;, &#8220;cup&#8221; or basically anything which is a three letter word starting with the letter &#8220;c&#8221; and ending with &#8220;p&#8221;.</p>
<p>Wildcard &#8220;%&#8221; :</p>
<p>&#8220;%&#8221; helps match any number of characters. Let&#8217;s take the same example as above:</p>
<p>select name from name_table where name like &#8220;c%p&#8221;</p>
<p>The output can be &#8220;cap&#8221;, &#8220;cop&#8221; and can also be &#8220;coooop&#8221;, &#8220;caawjshygfvsbchjsp&#8221; etc etc.</p>
<p>So what basically happens with &#8220;%&#8221; is that it will include any number of characters whereas &#8220;_&#8221; will include only one character.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techtamasha.com/wildcards_-and-in-sql/24/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Escape single quotes and wild cards &#8216;%&#8217; , &#8216;_&#8217; in MS SQL</title>
		<link>http://www.techtamasha.com/escape-single-quotes-and-wild-cards-_-in-ms-sql/20</link>
		<comments>http://www.techtamasha.com/escape-single-quotes-and-wild-cards-_-in-ms-sql/20#comments</comments>
		<pubDate>Mon, 24 Dec 2007 13:37:31 +0000</pubDate>
		<dc:creator>Nischal Shetty</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[escape ']]></category>
		<category><![CDATA[escape single quote]]></category>
		<category><![CDATA[Ms Sql escape character]]></category>

		<guid isPermaLink="false">http://techtamasha.com/?p=20</guid>
		<description><![CDATA[To escape single quotes ( &#8216; ) in MS SQL all you need to do is add two single quotes instead of one. Ex. If you want to insert the name D&#8217;souza into MS SQL the query goes like this: INSERT into name_column ([name]) VALUES (&#8216;D&#8221;Souza&#8217;) Look carefully. We have replaced single quote in between [...]]]></description>
			<content:encoded><![CDATA[<p>To escape single quotes ( &#8216; )  in MS SQL all you need to do is add two single quotes instead of one.</p>
<p>Ex. If you want to insert the name D&#8217;souza into MS SQL the query goes like this:</p>
<p>INSERT into name_column ([name]) VALUES (&#8216;D&#8221;Souza&#8217;)</p>
<p>Look carefully. We have replaced single quote in between the letter D and the word SOUZA with two <strong>SINGLE QUOTES</strong>. (It&#8217;s <strong>not</strong> a <strong>double quote</strong>)</p>
<p>Similarly, you may also face a problem while querying for values which contain the characters &#8216;%&#8217; and &#8216;_&#8217; in them. This is so because SQL considers these two characters as wild cards for multiple characters and single character string matching.</p>
<p>There are 2 ways to escape these wild cards.</p>
<p>1. You can use the <strong>default</strong> <strong>square braces</strong> &#8220;[]&#8221; like this- [%] or [_]</p>
<p>2. You can <strong>define</strong> your<strong> own escape</strong> character by using the <strong>keyword</strong> <strong>ESCAPE</strong> at the end of your where clause.</p>
<p>Ex. select * from name_column where name like &#8216;gyan\_sagar&#8217; <strong>ESCAPE</strong> &#8216;\&#8217;</p>
<p>In the example above we escape &#8220;_&#8221; by defining &#8220;\&#8221; as an escape character using the ESCAPE keyword.</p>
<p>Note: You can <strong>only define</strong> a <strong>single character</strong> for escaping and <strong>not</strong> a <strong>string</strong>.</p>
<p>I hope this post has made your work a bit more easier than before. Your suggestions and comments are always welcome. <img src='http://www.techtamasha.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.techtamasha.com/escape-single-quotes-and-wild-cards-_-in-ms-sql/20/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
