Showing posts with label path. Show all posts
Showing posts with label path. Show all posts

Monday, March 26, 2012

replace"***" in image path field.

I am hoping someone will be able to help me with this.
i have a table of accountholders with the following fields
account_no
account_name
image_path
the image_path field has a defaultvalue images/***.jpg
I am looking for a query code to update the value in the image_path field by replacing the *** value with the value of the

account_no fieldupdate accountholders
set image_path = replace(image_path, '***', account_no)

EDIT: safer would be:

update accountholders
set image_path = replace(image_path, '***', account_no)
where image_path='images/***.jpg'

Tuesday, March 20, 2012

replace a part of a string in a Table

hey,

I have a lage table with 1000's of records..
there is a column with the path to some files.

example: "R:\mutaties\test.pdf"

i need to change that path to "L:\archive\mutaties\test.pdf"

i will replace "R:\" with "L:\archive\" in all the records.. what;'s the simpelst way tot do this?

can i do a replace with SQL-queries? , or do i need to write a code/script for this?

grtz,
Blueupdate LargeTable
set Column = 'L:\archive' + substring(Column, 3, length(Column) - 3)
where Column like 'R:\%'|||Thanx Pierre ;)

I will try it :D

Friday, March 9, 2012

Repalce partial string in table

Hi! I need to replace a string in a SQL table with a new path.

Essentially, I want to find and replace the share path while retaining the rest of the path past that point.

I tried using Update (on a test table of course) but it sompley find and replaces with no regards to the rest of the path.

Any help is greatly appreciated!

JJDDL and some sample data would be helpful|||http://www.apcit.com/work/john.gif

I need to replace a portion of the path in the source column with a new vaule but still retain the rest of the text.

Hope this helps!

JJ|||DECLARE @.Path varchar(255), @.find varchar(25), @.replace varchar(25)

SELECT @.Path = 'C:\myTemp99\Brett\Folders\',@.find = 'Brett', @.replace = 'JJ'

SELECT @.Path = REPLACE(@.Path,@.find,@.replace)

SELECT @.Path|||Brett,

Thanks for your reply but how do I specify a table within the database?

For clarity:

I want to open a table, for a given object in the table I want to replace a portion of the value with a new one and append the rest of the data to the end of the new value.

www.apcit.com/work/john.gif

Essentially the path to the SOURCE has changed and I just want to find and repalce.

Thanks again!|||I'd try something like:UPDATE junque
SET pathname = Replace(pathname, '/work/', '/play/')
WHERE 0 < CharIndex(pathname, '/work/')Do check it out on a scratch table first though, this could cause havok if misused!

-PatP|||I'm actually using SQL query analyzer to run these, so please use that syntax.

Trying to resolve the @.PATH var specified in the earlier post. I'm formatting it something like this:

@.Path = 'sms_xxx.dbo.smspackages.source'

Is this correct? Basically sms_xxx is the DB. smspackages is the table and source is the column I want to find and replace the value in.

Any help is golden!

Thanks!

JJ|||Originally posted by jjrenner
I'm actually using SQL query analyzer to run these, so please use that syntax.

Trying to resolve the @.PATH var specified in the earlier post. I'm formatting it something like this:

@.Path = 'sms_xxx.dbo.smspackages.source'

Is this correct? Basically sms_xxx is the DB. smspackages is the table and source is the column I want to find and replace the value in.

Any help is golden!

Thanks!

JJ These all seem to be acceptable syntax for SQL Query Analyzer.

The @.path in Brett's example was a declared variable that he was using to illustrate the concept.

I'd suggest that you use something vaguely like:UPDATE sms_xxx.dbo.smspackages
SET source = Replace(source, 'original', 'new')-PatP|||Pat,

Worked like a charm. Thanks for the baby steps!

JJ