Solved

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

Posted on 2007-11-23
5
192 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
ID: 20339345
select
          'Text' + COALESCE(Col1,xyz)
from table2
0
 
LVL 6

Expert Comment

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

Expert Comment

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

Expert Comment

by:Computer101
ID: 20953228
Forced accept.

Computer101
Community Support Moderator
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

809 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