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
 Copy one column1 Table A, to column2 Table B
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

reading2009
Starting Member

22 Posts

Posted - 12/29/2009 :  14:22:33  Show Profile  Reply with Quote
Hi,

I am looking for copy data from one column from one table(1st) to another column in the 2nd table.

But I want the out in the 2nd table in a particular way.

ColumnA in 1st table
abc
def
ghi
dgy

Desired output in 2nd table
ColumnB
abc,def,ghi,dgy

I tried
INSERT INTO TestTable (FirstName, LastName)
SELECT FirstName, LastName
FROM Person.Contact

but i get the output same as 1st table.

Any help here....

vijayisonly
Flowing Fount of Yak Knowledge

USA
1836 Posts

Posted - 12/29/2009 :  14:29:54  Show Profile  Reply with Quote
Can you provide some more information..table structures??

So you have a single column (probably FullName) in table 2 and you want to insert the value "FirstName,LastName" from table 1 into this new column in table2?

Go to Top of Page

reading2009
Starting Member

22 Posts

Posted - 12/29/2009 :  14:42:33  Show Profile  Reply with Quote
Yes, you are right. I want different rows in coulmn a in 1st table to appear in 1 row, comma seperated values in column b of second table.
Go to Top of Page

vijayisonly
Flowing Fount of Yak Knowledge

USA
1836 Posts

Posted - 12/29/2009 :  15:06:17  Show Profile  Reply with Quote
Have a look at this topic to see how to concatenate without a UDF.

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=81254
Go to Top of Page

reading2009
Starting Member

22 Posts

Posted - 12/30/2009 :  09:42:04  Show Profile  Reply with Quote
Thank you. I will go through your material today and give it a try.
Go to Top of Page

vijayisonly
Flowing Fount of Yak Knowledge

USA
1836 Posts

Posted - 12/30/2009 :  10:01:30  Show Profile  Reply with Quote
You're welcome. Post back if you face any difficulties (along with sample data this time ).
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 1.86 seconds. Powered By: Snitz Forums 2000