473,804 Members | 3,649 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using a sql statement to do a string replace

I am not certain which group to post this to - sorry if this is the wrong
group:

I have a table that holds the location of various media and such (mostly
images). One field is the Media name, the other is the URL in the form
http://myServer.gunnery.org/media/pic1 for example. we are about to move
all the media to a new location (new server). the paths will remain the
same except for the server name.

Is there an update statement that will let me go through the table an
replace myServer with newServer in all the URLs (and leave the rest of the
URL alone). So the link above would become
http://newServer.gunnery.org/media/pic1. I know how I would do it with VB,
but I am not as familar with all the tricks in SQL.

thanks

bj daniels
da******@gunner y.org
Nov 17 '05 #1
2 1220
You should be able to use the REPLACE function. This select statement should show you that it works as expected:

SELECT REPLACE(MediaNa me, 'myServer.gunne ry', 'newserver.gunn ery') FROM YourTable
After verifying that the select gives you the expected result, run the following update to update the data within the table:

--UPDATE YourTable SET MediaName = REPLACE(MediaNa me, 'myServer.gunne ry', 'newserver.gunn ery')
--SELECT @@rowcount AS RowsUpdated

--
Keith

"bj daniels" <da******@gunne ry.org> wrote in message news:eN******** ******@TK2MSFTN GP12.phx.gbl...
I am not certain which group to post this to - sorry if this is the wrong
group:

I have a table that holds the location of various media and such (mostly
images). One field is the Media name, the other is the URL in the form
http://myServer.gunnery.org/media/pic1 for example. we are about to move
all the media to a new location (new server). the paths will remain the
same except for the server name.

Is there an update statement that will let me go through the table an
replace myServer with newServer in all the URLs (and leave the rest of the
URL alone). So the link above would become
http://newServer.gunnery.org/media/pic1. I know how I would do it with VB,
but I am not as familar with all the tricks in SQL.

thanks

bj daniels
da******@gunner y.org

Nov 17 '05 #2
Looks Perfect - thanks!
"Aaron Bertrand - MVP" <aa***@TRASHasp faq.com> wrote in message
news:eP******** ******@TK2MSFTN GP10.phx.gbl...
UPDATE table SET mediaName = REPLACE(mediaNa me, '//myServer', '//newServer') WHERE CHARINDEX('//myServer', mediaName) > 0
"bj daniels" <da******@gunne ry.org> wrote in message
news:eN******** ******@TK2MSFTN GP12.phx.gbl...
I am not certain which group to post this to - sorry if this is the wrong group:

I have a table that holds the location of various media and such (mostly
images). One field is the Media name, the other is the URL in the form
http://myServer.gunnery.org/media/pic1 for example. we are about to move all the media to a new location (new server). the paths will remain the
same except for the server name.

Is there an update statement that will let me go through the table an
replace myServer with newServer in all the URLs (and leave the rest of the URL alone). So the link above would become
http://newServer.gunnery.org/media/pic1. I know how I would do it with

VB,
but I am not as familar with all the tricks in SQL.

thanks

bj daniels
da******@gunner y.org


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
6707
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft Visual Basic .NET version of this article, see 308049. For a Microsoft Visual C++ .NET version of this article, see 310071. For a Microsoft Visual J# .NET version of this article, see 320627. This article refers to the following Microsoft .NET...
28
20348
by: Daniel | last post by:
Hello =) I have an object which contains a method that should execute every x ms. I can use setInterval inside the object construct like this - self.setInterval('ObjectName.methodName()', this.pinginterval); - but is there no way to do this without using the literal ObjectName? If I write 'this.methodName()' I get "Line 1 Char 1: Object doesn't support this property or method." in IE, and nothing happens in Firebird.
2
11131
by: Hasan Ammar | last post by:
Is it possible to set up hotkeys using onkeypress? I know it can be done with the usual alphanumeric keys, but what about function keys? or using ctrl/alt combinations? Does anybody have a tutorial/guide?
4
2718
by: Japhy | last post by:
Hello, I'm am pulling data from a mysql db and want to use the data to populate a <ul. Here are relavent parts of my code : $wohdate = mysql_result($wohRS,$wohndx,woh_date); $woh_display .="<li>".$wohdate."</li>" ; $TemplateText = Replace($TemplateText,"@$wohdisplayndx@",$woh_display);
11
6607
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on where the job is running, the job runs sucessfully, PDF files got generated, everything is good. If I scheduled the job to run at the time that I am not logged into the server, Access is not able to print to the printer. The error is pretty...
19
78850
by: Paul | last post by:
hi, there, for example, char *mystr="##this is##a examp#le"; I want to replace all the "##" in mystr with "****". How can I do this? I checked all the string functions in C, but did not find one.
1
19854
by: Craig Kenisston | last post by:
Hi, I need to write a function that should behave like the SQL's "like" operator on a list of words. I was wondering if I can use Regex directly to do this job. But I've been reading about regex and it supports very different characters and behaves different. So, I'm looking for an advise. I'd like to know if it is feasable or not, I mean, if dotnet Regex implementation could handle it.
12
1864
by: TB | last post by:
Hi All: I am trying to create a variation on the standard datagrid, whereby the datagrid is only shown after pressing some buttons. This reason for this is that I would like to use the same datagrid for several tables, and the idea is that the button events store the the SQL select statement and the SQL update statement in view state items, which can the be reused for all the datagrid events (paging and editing). However I seem to...
10
3576
by: Chris H | last post by:
Greetings, I'm trying to update an address field with "standard" abbreviations so that I can do a comparison of various accounts to one another on the address. I can update a set of records for "Road" to "Rd", but when I tried to stack the update clauses, I seem to get random updates within the file. All the updates are correct, but they're incomplete. Not sure how this needs to be done, I added a TOP statement but that didn't work. ...
0
9576
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10567
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10323
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10074
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7613
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5515
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4291
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3809
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2983
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.