Thursday, May 24, 2012

Get data from sqlserver without null values


I have a table like below structure

FName   MName   LName

Gaurav   NULL       Kumar

Piyush    Sharma   NULL

How can I write a query so that I can get an output  without null values. I dont want them in my result.
Gaurav Kumar
Piyush Sharma

here is the solution

 select IsNull(FName,'') + ' ' + IsNull(MName,'') + ' ' + IsNull(LName,'') from tableName   




IsNull function checks first paramter…. if it is null then second parameter is returned else first parameter is returned as it is.

No comments:

Post a Comment

LinkWithin

Related Posts Plugin for WordPress, Blogger...