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
 Site Related Forums
 Article Discussion
 Find and Replace Partnumbers in string
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

minimotorsport
Starting Member

Germany
13 Posts

Posted - 03/26/2002 :  19:26:52  Show Profile  Visit minimotorsport's Homepage  Reply with Quote
I have product database (webkatalog) with a string field (Detail) witch may contain one or more Partnumbers.
I want to put tags around them , if the Partnumber is also in the database.

I have tried some:

Replace(Detail,partnumber,"<B>" + partnumber +"</B>")

but can not find the right Select to find all partnumbers.



yours faithfully

Michael

MichaelP
Jedi Yak

USA
2489 Posts

Posted - 03/26/2002 :  20:26:21  Show Profile  Visit MichaelP's Homepage  Reply with Quote
Take a look at:
http://sqlteam.com/item.asp?ItemID=1876

That shows you how to find keywords in a varchar field in a table. You should be able to apply the same concepts to find the partnumbers in your field. If I'm reading correctly, I think what you wnt to do is put all the part numbers into a temp table that contains the RecordId and the partnumber. Each RecordID could have multiple part numbers associated with it. Once you have this table, you should be able to fairly easily update the "detail" field by selecting from this temp table.

Could you also post a few sample records of the "Detail" field? That would greatly help as well.

Go to Top of Page

rrb
SQLTeam Poet Laureate

Australia
1479 Posts

Posted - 03/26/2002 :  21:00:07  Show Profile  Reply with Quote
Hi minimotorsport

From what you said, I think you've got a table like this:
PARTNUMBER DETAIL
----------------------
PART01 PART02, PART08, PART04
PART02 NULL
PART03 PART05
PART04 PART06, PART07, PART08
PART05 NULL

And you want

PARTNUMBER DETAIL
----------------------
PART01 <b>PART02</b>, PART08, <b>PART04</b>
PART02 NULL
PART03 <b>PART05</b>
PART04 PART06, PART07, PART08
PART05 NULL


Is that right?

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page

minimotorsport
Starting Member

Germany
13 Posts

Posted - 03/27/2002 :  04:29:35  Show Profile  Visit minimotorsport's Homepage  Reply with Quote
yes. Any idea ?


yours faithfully

Michael
Go to Top of Page

minimotorsport
Starting Member

Germany
13 Posts

Posted - 03/27/2002 :  05:28:17  Show Profile  Visit minimotorsport's Homepage  Reply with Quote
quote:

Take a look at:
http://sqlteam.com/item.asp?ItemID=1876

That shows you how to find keywords in a varchar field in a table. You should be able to apply the same concepts to find the partnumbers in your field. If I'm reading correctly, I think what you wnt to do is put all the part numbers into a temp table that contains the RecordId and the partnumber. Each RecordID could have multiple part numbers associated with it. Once you have this table, you should be able to fairly easily update the "detail" field by selecting from this temp table.

Could you also post a few sample records of the "Detail" field? That would greatly help as well.





partnumber Detail
____________ ______________________________________________
1 like that in blue use 3 or 4
2 you better use 6
3 8 is cheaper
4 you can also use 1 for that
5
6 better than 2
7

and thats what I want to have:


partnumber Detail
____________ __________________________________________________
1 like that in blue use <B>3</B> or <B>4</B>
2 you better use <B>6</B>
3 8 is cheaper
4 you can also use <B>1</B> for that
5
6 better than <B>2</B>
7





yours faithfully

Michael
Go to Top of Page

minimotorsport
Starting Member

Germany
13 Posts

Posted - 03/27/2002 :  12:52:02  Show Profile  Visit minimotorsport's Homepage  Reply with Quote
how can I do the following ?

for every [Artikelnummer] from webkatalog

do the following

Replace(Detail,[Artikelnummer],"<B>"+[Artikelnummer]+"</B>")
from webkatalog

something like that.




yours faithfully

Michael
Go to Top of Page

rrb
SQLTeam Poet Laureate

Australia
1479 Posts

Posted - 04/01/2002 :  19:52:58  Show Profile  Reply with Quote
Sorry, but I can't see any easy way. I think you're going to probably (dare I say it)
* cursor through each record
* loop through each ocurrence of partnumber in each string
* check for a match and insert
<b></b>
tags as required

Someone else may know a better method, but straight after the easter long-weekend - quite frankly I can't see it...

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
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