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
 concat query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

chbala85
Starting Member

49 Posts

Posted - 07/11/2013 :  08:10:03  Show Profile  Reply with Quote


Hi all,

i have table it's having 10 columns.Here fisrtname ,lastname column need to concat and stored to fullname column but lastname some times having null values also.

That fullname column data to insert into another table test2.
Heere fullname column datatype is varchar.


help me..............

best regards,

krsh.

James K
Flowing Fount of Yak Knowledge

3559 Posts

Posted - 07/11/2013 :  08:11:49  Show Profile  Reply with Quote
INSERT INTO YourNewTable (FullName)
SELECT COALESCE(FirstName + ' ','') + COALESCE(LastName,'')
FROM YourOriginalTable
Go to Top of Page

MuMu88
Aged Yak Warrior

547 Posts

Posted - 07/11/2013 :  08:44:53  Show Profile  Reply with Quote
Or If you SQL 2012 you can do this:


INSERT INTO YourNewTable (FullName)
SELECT CONCAT(FirstName + ' ', LastName)
FROM YourOriginalTable
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.08 seconds. Powered By: Snitz Forums 2000