SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 If SQL Statement in access
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

junior6202
Starting Member

USA
32 Posts

Posted - 05/15/2014 :  11:49:12  Show Profile  Reply with Quote
So I'm new to SQL and I was asked to populate a table so I did and some of the columns where missing information and was told to write an "If Statement that would say if column A is null then use columns of second table". Any advice would be appreciated.

Thank you.

tkizer
Almighty SQL Goddess

USA
37460 Posts

Posted - 05/15/2014 :  12:32:43  Show Profile  Visit tkizer's Homepage  Reply with Quote
I can only help with SQL Server, but are you wanting an UPDATE to fix the data or an INSERT to fix the import? Where is the source data?

INSERT INTO t1 (c1, c2, c3, c4)
SELECT T2.c1, T2.c2, T2.c3, CASE WHEN T2.c4 IS NOT NULL THEN T2.c4 ELSE T3.c4 END
FROM T2
JOIN T3 ON T2.c1 = T3.c1


Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000