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
 Transact-SQL (2000)
 update query help required please

Author  Topic 

icw
Constraint Violating Yak Guru

378 Posts

Posted - 2006-08-24 : 07:49:10
Hi I want to update a field - partially!.

What i mean is;
currently the field will contain a path to a file e.g.
'\\Old_server1\files\customer1\test.xls'
I want to do an update query to update the first part;
so that it looks like;
\\New_server2\files\customer1\test.xls

Can I do this somehow?

Thanks

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-08-24 : 07:51:36
??

Update TableName Set Columnname = replace(ColumnName,'Old_server1','New_server2')



Chirag
Go to Top of Page

icw
Constraint Violating Yak Guru

378 Posts

Posted - 2006-08-24 : 08:24:57
I don't think I explained properly.
The whole path stored is a string not individual columns

thanks

ICW
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-08-24 : 08:27:19
Update TableName Set FIELD = replace(FIELD, 'Old_server1', 'New_server2')

Peter Larsson
Helsingborg, Sweden
Go to Top of Page

icw
Constraint Violating Yak Guru

378 Posts

Posted - 2006-08-24 : 08:52:53
Thanks to you both actually,
I didn't realise at first the first response answered my question too.
icw
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-08-24 : 08:53:08
quote:
Originally posted by icw

I don't think I explained properly.
The whole path stored is a string not individual columns

thanks

ICW



you need to read about replace function in BOL...

Chirag or peso's query will replace word 'Old_server1', wherever found in the path, with the word 'New_server2'. It is not replacing the individual column !!

Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-08-24 : 08:54:41
All I did was to replace COLUMN to FIELD.
Not all Access developers understands this is the same.

Peter Larsson
Helsingborg, Sweden
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-08-24 : 11:12:11
quote:
Originally posted by Peso

All I did was to replace COLUMN to FIELD.
Not all Access developers understands this is the same.

Peter Larsson
Helsingborg, Sweden



I didn't blame you...but how do you know he/she is an Access developer

Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page
   

- Advertisement -