Solved

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

Posted on 2007-11-23
5
193 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Solar Winds can't see SQL Server Express 17 38
Requesting help with creating an SQL query with 2 tables 6 27
SQLCMD Syntax 2 17
Pivot tables in SQL 1 20
Creating and Managing Databases with phpMyAdmin in cPanel.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
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
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

821 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