?
Solved

need to remove null values from the below query in sqlserver2005

Posted on 2011-04-24
6
Medium Priority
?
361 Views
Last Modified: 2012-05-11
Hi
pls provide me query for the beolw
write a query to remove null value follwing table?
col1   col2   col3
dinesh null   null
null   suresh  null
null   null    prakesh

i want the output

col1     col2   col3
dinesh  suresh  prakesh
Regards
Ravi
0
Comment
Question by:mu_ravi1
6 Comments
 
LVL 21

Expert Comment

by:Alpesh Patel
ID: 35458264
What should be the output is source is like below:


col1   col2   col3
dinesh null   alpesh
null   suresh  null
null   null    prakesh
0
 
LVL 9

Accepted Solution

by:
kaminda earned 2000 total points
ID: 35458280
You can use below code to getrid of nulls


SELECT ISNULL(col1,''), ISNULL(col2,''),   ISNULL(col3,'') FROM TableName

Open in new window

0
 
LVL 41

Expert Comment

by:Sharath
ID: 35458311
do you need this?
select max(col1) col1,max(col2) col2,max(col3) col3
  from your_table

Open in new window

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:mu_ravi1
ID: 35458314
PatelAlpesh

yes  i want the source like that.
Ravi
0
 
LVL 9

Expert Comment

by:kaminda
ID: 35458795
You can do something like this


SELECT 
(SELECT col1 FROM tablename WHERE col1 IS NOT NULL),
(SELECT col2 FROM tablename WHERE col2 IS NOT NULL),
(SELECT col3 FROM tablename WHERE col3 IS NOT NULL)

Open in new window

0
 

Author Closing Comment

by:mu_ravi1
ID: 35727878
good
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Mark Wills PIVOT is a great facility and solves many an EAV (Entity - Attribute - Value) type transformation where we need the information held as data within a column to become columns in their own right. Now, in some cases that is relatively…
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question