Ignore whitespace in Beyond Compare

When you compare code using Beyond Compare and see a big red block of difference, many times the difference is actually just of tabs or space. It can be set as not-important text and then Beyond Compare can hide these differences.

Here is how you can ignore the leading and trailing whitespace:

Beyond Compare 3

Start with comparing two file. In the window that comes up, go to Session menu, and click Session Settings. Switch to Importance tab, and there you go! Things are a bit differently organized, but it’s here.

Important Note: Do not forget to change the value of the bottom dropdown to  “Also update session defaults”.

Beyond Compare 2

Go to Tools > Options > Rules. Select  “Everything Else ” at the bottom. Click Edit. Go to Importance tab and check Leading Whitespace and Trailing Whitespace. Finally, close all boxes. That”s it!

Here I have assumed that you are comparing aspx or .vb/.cs files. If you are comparing file types which are defined in Beyond Compare, you need to select the appropriate rule instead of everything else.

Confessions by Oracle

Even Oracle admits it 🙂


Source: docs.oracle.com

Format Decimal Datatype with Commas in T-SQL

Note: This is approach is actually NOT recommended. Better idea would be to do all the formatting on UI.

Ever fall into a situation where a column is a Decimal, and you want the output to have a comma after every three digits?
T-SQL’s CONVERT function can do it for you. The syntax of the function is:
CONVERT ( data_type [ ( length ) ] , expression [ , style ] )

Here, we will be utilizing the power of the last parameter style. The style can be set to the following three values, when converting money datatype into a character datatype:

0 – No commas and only 2 decimal points
1 – Commas every 3 digits, and only 2 decimal points
2 – No command, and 4 decimal points.

Now since, the datatype stored in the table is actually decimal, we first need to convert it into money, and then convert it into varchar or char.

select convert(varchar(50),convert(money,'54120000.2154'),1)

The result would be:

-------------------- 54,120,000.22 (1 row(s) affected) Simple. Isn’t it?

XML Data Truncated with SqlDatareader

I was working on XML feeds for my site and found a strange problem.

The XML returned by the SP was getting truncated. After ‘googling’ for a while, I found this on MSDN:
The XML data row is truncated at 2,033 characters when you use the SqlDataReader object

When you read Extensible Markup Language (XML) data from Microsoft SQL Server by using the SqlDataReader object, the XML in the first column of the first row is truncated at 2,033 characters. You expect all of the contents of the XML data to be contained in a single row and column.

This was exactly my problem. I found the solution as well. The solution is to use  ExecuteXmlReader  instead of SqlDataReader .


You can see the detailed articles here and here.


Why NULL equals NULL is False

NULL has a special meaning. This was created to fulfill the need of having a character, that means ’nothing’ and it equals ’nothing’. So, it doesn’t even equal itself. Suppose, you have a column named ’PRICE’ in your table with datatype ‘money’. For a particular product, you don’t have data for price. How would you store it? Store a zero? But that would mean that the product is free!

Consider another scenario. You have a table, where you store the comments written by visitors on your site. Whenever a comment is written, you have to either approve it or disapprove it. If you disapprove, a ‘sorry’ mail is sent, if you approve, that comment is shown on your site, and a ‘thank you’ mail is sent. In this case, what would be the value of the column ‘approved’ initially?

Above two cases make a good case for storing a NULL.

Now the problem, how would you search for NULL in your query? The obvious answer would be to use something like:

select * from sometable where somecolumn=NULL

But above will NOT work. The reason is NULL is a special character and it equals nothing, not even it self. So, the solution to this problem is the IS NULL operator:

select * from sometable where somecolumn IS NULL

This works perfectly. Another solution is to set ANSI_NULLS to off:

This will work fine as well. The reason for this is compliance to SQL-92 standards. When you set ANSI_NULLS to off, you are actually turning off the compliance to SQL-92 standards. Read more about it here.

Happy Coding!

View Page Source When Right-Click is Disabled with Wizton

Migrating from old blog.
Orignially Posted: 04 Oct, 2007

There are instances the page uses frames, and you want to view the page source. If you do View > Source, it will not show you the source of the page that you want to view, but only the container page. You could right click and say view source, but then there are certain sites which have disabled right click using javascript. What would you do then?

Solution: Use Maxthon browser.

In the bottom right of the browser, you will see a button that says “Force Open Links in New Tabs”.

Before clicking a link, that will opens the page in the frame, click this button. Now the pages will open in a new tab. (You can turn it off later if it is irritating). You will have the page opened in a new tab without frames. Now you can always use the View > Source menu option.

Simple but useful tip I would say.