Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Concatenating columns

Author  Topic 

aniko
Starting Member

25 Posts

Posted - 2012-01-17 : 00:58:17
Hi team,

I have birth_day, birth_month, birth_year

I also have an empty column named birth_date in the same table.

How do I concatenate the birth date data into the birth_date field?

cheers,
aniko

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2012-01-17 : 01:38:59
If you mean string concatenation then something like :
SELECT 'birth_day' + 'birth_month' + 'birth_year' as birth_date .....

If you mean UPDATE the "birth_date" something like:
UPDATE myTable SET
birth_date = birth_day + birth_month+birth_year

Depending on the data type you'll need to CAST to relevant data type

Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page

aniko
Starting Member

25 Posts

Posted - 2012-01-17 : 16:48:22
Thank you! Works great.
Go to Top of Page

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2012-01-18 : 10:24:30
Your welcome

Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page
   

- Advertisement -