Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

Tip to Handle Nulls in SQL SERVER 2005

Author: DevASP Team

Here I will try to give you a tip to handle NULLS that can make your result set disturbed and generate unwanted values which can make you to face many irritating problems.

While working with Store procedures and database application we perform join operations and specifically in Left outer join or in Right outer join Null record also come. To handle these nulls so that at front end may not make your application crash perform the ISNULL checks. In SQL Server ISNULL is a method that overwrites the null value with your desired value and you can handle nulls easily base on the output of you query.

 

The simple syntax of ISNULL is as follows:

 

ISNULL(value to check, value to replace)

 

For example:

 

          ISNULL(EMP.E_SAL, 0.00)

 

 

The value which overwrite the null values is based on the data type of the column if for example the data type of column is INT then this value can be ranges from ‘0,1,2,…,n’. so all it depends on your choice and if it is bit it will ranges between ‘0,1’ because bit has only two options either true that is ‘1’ or false that is ‘0’. With nulls you can also compare values and perform any kind of arithmetic operations this will not restrict you in any case but it will provide you a safe guard that will help you in making your code more reliable.

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Paging in SQL Server 2005 Database

Disclaimer - Privacy
© 2002-2017 DevASP.net