943,649 Members | Top Members by Rank

Ad:
  • MS SQL Discussion Thread
  • Unsolved
  • Views: 13825
  • MS SQL RSS
Nov 29th, 2006
0

Howto | mssql seach and replace?

Expand Post »
In my database, I have two tables: Forum and Files

Files have two fields. First one is FileID and second one is FileAddress.

FileId field is fine. but in FileAddress field I have a lot of urls. I want to just change certain parts of url. For example, instead of having http://ipaddress/FILEPATH

I want to chage that to http://domain.com/FILEPATH for about 400 data in the sql table. How do I do this?????
Similar Threads
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
desiguru is offline Offline
63 posts
since Aug 2006
Jan 15th, 2007
0

Re: Howto | mssql seach and replace?

Click to Expand / Collapse  Quote originally posted by desiguru ...
In my database, I have two tables: Forum and Files

Files have two fields. First one is FileID and second one is FileAddress.

FileId field is fine. but in FileAddress field I have a lot of urls. I want to just change certain parts of url. For example, instead of having http://ipaddress/FILEPATH

I want to chage that to http://domain.com/FILEPATH for about 400 data in the sql table. How do I do this?????
Hi Desiguru,
You could use the stuff function e.g.
stuff( 'http://ipaddress/FILEPATH', 8, 9, 'domain.com')
this will replace from character 8 the 9 characters 'ipaddress' with 'domain.com'
but you would obviously replace the string to be modified with the field name

stuff( FileAddress, 8, 9, 'domain.com')

and you would obviously need to select the appropriate records

Regards

Rob
Reputation Points: 10
Solved Threads: 0
Newbie Poster
RobStocks is offline Offline
7 posts
since Jun 2006
Jan 16th, 2007
0

Re: Howto | mssql seach and replace?

Also, look at the SUBSTITUTE function
MCP
Reputation Points: 14
Solved Threads: 3
Light Poster
MCP is offline Offline
44 posts
since Sep 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MS SQL Forum Timeline: SQL 2005 upgrade questions
Next Thread in MS SQL Forum Timeline: problem with trigger





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC