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.
Author |
Topic |
PGG_CA
Starting Member
24 Posts |
Posted - 2012-06-20 : 13:04:05
|
... single field in another table.I need to copy the data from multiple fields in a table and put everything into a single field in another table.For example:Table1fields:f1 f2 f3 f4 f5data: True 123 this is the problem. called support 25.15After the query,Table2field: col1data: True, 123, this is the problem., called support, 25.15How do I best accomplish this? Thanks for any help. |
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2012-06-20 : 13:13:57
|
INSERT INTO Table2SELECT f1+ ',' + f2 + ',' + f3 + ',' + f4 + ',' +f5FROM table1JimEveryday I learn something that somebody else already knew |
 |
|
Gigabyte
Starting Member
30 Posts |
Posted - 2012-06-20 : 13:51:15
|
SELECT * INTO <DESTINATION_TABLE> FROM <SOURCE_TABLE>NOTE: DESTINATION_TABLE WILL AUTOMATICALLY BE CREATED WHEN YOU EXECUTE ABOVE QUERY. PLEASE GIVE A NEW NAME FOR DESTINATION TABLE WHICH IS NOT IN THE DB.GIGABYTE+ |
 |
|
PGG_CA
Starting Member
24 Posts |
Posted - 2012-06-20 : 16:00:48
|
I tried using the + in my select statment, but I get the error " The data types varchar and text are incompatible in the add operator". |
 |
|
PGG_CA
Starting Member
24 Posts |
Posted - 2012-06-20 : 16:07:12
|
Fixed it. I used the convert function to 'convert' text to varchar. |
 |
|
Gigabyte
Starting Member
30 Posts |
Posted - 2012-06-21 : 08:24:51
|
If you are concatenating, I believe you need to use cast or convert . .If you provide the query you are using, we could modify it.GIGABYTE+ |
 |
|
|
|
|