Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 update sunstrings of column

Author  Topic 

angusl
Starting Member

6 Posts

Posted - 2006-03-30 : 04:48:06
Is it possible to use SUBSTRING with update to replace only part of a column , e. g.
Update ... set Substring(col1,1,5) = "Fred" where Substring(col1,1,4)="Eric"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-03-30 : 04:53:05
Post some sample data and the result you want

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2006-03-30 : 04:53:53
Have a look at the stuff function.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

angusl
Starting Member

6 Posts

Posted - 2006-03-30 : 08:20:36
Stuff function looks useful, but I need to replace "\\oh6svr" with "\\cqfileclus". Perhaps I could ask for a share to be defined the same length as the original string ?
Thanks,
Angus
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-03-30 : 08:27:32
Start with this
Declare @t table(data varchar(100))
insert into @t
select 'test' union all
select '"\\oh6svrTest'
Select replace(data,'\\oh6svr','\\cqfileclus') from @t


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-03-30 : 08:28:05
angus,

Can u post "some" ( > 1) sample data and the results u expect

Srinika
Go to Top of Page

angusl
Starting Member

6 Posts

Posted - 2006-03-30 : 11:39:28
Thanks all, we did use replace and got it sorted.
Angus
Go to Top of Page
   

- Advertisement -