|
-
Aug 9th, 2012, 05:07 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] How to replace portion of string in field in table
Hello: I have a table that has a field called attachFilename
currently, all the records are poulated for this field with a string such as "\\companydrive\g-drive\company_TEST\Job_12\Job_12.dwg"
and I need to replace this portion of the string: "\\companydrive\g-drive\company_TEST" with a different string.
Is there an easy way to do this with sql?
I'm using sql express 2008.
thanks,
Proctor
-
Aug 10th, 2012, 05:30 AM
#2
Re: How to replace portion of string in field in table
Look into REPLACE
select replace('\\companydrive\g-drive\company_TEST\Job_12\Job_12.dwg','Company_TEST','with this')
-
Aug 10th, 2012, 05:49 AM
#3
Re: How to replace portion of string in field in table
Here is a better example:
Code:
create table #VBForums(MyText Varchar(200))
insert into #VBForums(mytext) values('\\companydrive\g-drive\company_TEST\Job_12\Job_12.dwg')
Update #VBForums
set MyText = replace('\\companydrive\g-drive\company_TEST\Job_12\Job_12.dwg','Company_TEST','with this')
where myText = '\\companydrive\g-drive\company_TEST\Job_12\Job_12.dwg'
select * from #VBForums
drop table #VBForums
-
Aug 10th, 2012, 10:50 AM
#4
Thread Starter
Fanatic Member
Re: How to replace portion of string in field in table
That's awesome!! Thanks .......
Proctor
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|