Solved

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

Posted on 2007-11-23
5
195 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Do you have a plan for Continuity?

It's inevitable. People leave organizations creating a gap in your service. That's where Percona comes in.

See how Pepper.com relies on Percona to:
-Manage their database
-Guarantee data safety and protection
-Provide database expertise that is available for any situation

Question has a verified solution.

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

Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

617 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