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
 Search string and update row.

Author  Topic 

maevr
Posting Yak Master

169 Posts

Posted - 2008-01-18 : 06:51:49
I have at table that I want to update using another table which contains other values than those in the text column.
table1
id: text:
1 1111, 2222, 3333
2 1234, 2222
3 0123

table2
id: str:
1111 aaaa
2222 bbbb
3333 cccc
1234 qqqq
0123 oooo

I want to replace the text in table1 with the new values so that it looks like below:
table1
id: text:
1 aaaa, bbbb, cccc
2 qqqq, bbbb
3 oooo

My first idea was to split the text column in table1 and insert every new text with its id in a temporary table and then concaternate a new string and update the column.
But how do I manage this?

raaj
Posting Yak Master

129 Posts

Posted - 2008-01-18 : 08:58:18
is thr any other common field between table1 and table2???
Go to Top of Page

maevr
Posting Yak Master

169 Posts

Posted - 2008-01-20 : 16:14:40
Thanks for your reply!
No, there is no other values.

How can I split the string in the text column so that all strings (except the comma) can be placed as a new row in a temporary table?
Go to Top of Page

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2008-01-21 : 03:10:02
There are some good split string functions on http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=50648.


Jack Vamvas
--------------------
Search IT jobs from multiple sources- http://www.ITjobfeed.com
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-01-21 : 08:51:24
Also read about normalization

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -