Solved

sql: i need a logic that would allow me to check whether column is empty

Posted on 2007-11-23
5
190 Views
Last Modified: 2010-03-20
i am doing the following:

insert  table1
select
          'Text' + ifnotnul(col1) else xyz
from table2

how do i correctly specify in sql:  'Text' + ifnotnul(col1) else xyz.
0
Comment
Question by:gogoshar
  • 2
5 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 500 total points
Comment Utility
select
          'Text' + COALESCE(Col1,xyz)
from table2
0
 
LVL 6

Expert Comment

by:wshark83
Comment Utility
select case when <col1> <> ' ' then <col1> else 'xyz' end as <Newcolumnname>
from <tablename>
0
 
LVL 6

Expert Comment

by:wshark83
Comment Utility
sorry also just add text + ' ' + before case statement
0
 
LVL 1

Expert Comment

by:Computer101
Comment Utility
Forced accept.

Computer101
Community Support Moderator
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

763 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

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now