Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

sql combine 2 date fields into 1

Posted on 2013-01-06
1
Medium Priority
?
299 Views
Last Modified: 2013-01-06
I have a table like this:
ID    date1                                    date2
1      2012-08-23 00:00:00.000     NULL
2      NULL                                     2012-07-04 00:00:00.000
3      2012-08-13 00:00:00.000      NULL



need a query to produce this output?
ID    date
1      2012-08-23 00:00:00.000    
2      2012-07-04 00:00:00.000
3      2012-08-13 00:00:00.000
0
Comment
Question by:JCTDD
1 Comment
 
LVL 17

Accepted Solution

by:
Kent Dyer earned 2000 total points
ID: 38749600
use CASE

CASE WHEN date1 IS NULL THEN date2, ELSE date1 END As Date_selected

HTH,

Kent
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Integration Management Part 2
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

824 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