|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Update HelpHow can I update data on this column called address1. The path is
'c:\apps\MailBox\Attach\El Poder' and I want it changed to 'c:\apps\Sever1\MailBox\Attach\El Poder' *** Sent via Developersdex http://www.developersdex.com *** Hi Sean,
UPDATE SomeTable SET address1 = 'c:\apps\Sever1\MailBox\Attach\El Poder' WHERE address1 = 'c:\apps\MailBox\Attach\El Poder' HTH, Jens Suessmeyer. I'm sorry the path may different documents such as
I have a lot of documents that are in this location c:\apps\MailBox\Attach\ and need them all switched to this location c:\apps\Sever1\MailBox\Attach\ example 'c:\apps\MailBox\Attach\El Poder' 'c:\apps\MailBox\Attach\Word1.doc' 'c:\apps\MailBox\Attach\Word2.doc' 'c:\apps\MailBox\Attach\Word3.doc' 'c:\apps\MailBox\Attach\Word4.doc' 'c:\apps\MailBox\Attach\Word5.doc' I need to change them to c:\apps\Sever1\MailBox\Attach\Word1.doc' c:\apps\Sever1\MailBox\Attach\Word2.doc' c:\apps\Sever1\MailBox\Attach\Word3.doc' c:\apps\Sever1\MailBox\Attach\Word4.doc' Again its a lot of documents. I update each one indivually I need to update all *** Sent via Developersdex http://www.developersdex.com *** sean,
based on your description, this should do: create table paths(path varchar(50)) go insert paths select 'c:\apps\MailBox\Attach\El Poder' union all select 'c:\apps\MailBox\Attach\Word1.doc' union all select 'c:\apps\MailBox\Attach\Word2.doc' union all select 'c:\apps\MailBox\Attach\Word3.doc' union all select 'c:\apps\MailBox\Attach\Word4.doc' union all select 'c:\apps\MailBox\Attach\Word5.doc' update paths set path=stuff(path,9,0,'Server1\') dean Show quote "Sean John" <s*@aol.com> wrote in message news:eisIgpsHGHA.2896@TK2MSFTNGP09.phx.gbl... > I'm sorry the path may different documents such as > > I have a lot of documents that are in this location > > c:\apps\MailBox\Attach\ > > and need them all switched to this location > > > c:\apps\Sever1\MailBox\Attach\ > > example > 'c:\apps\MailBox\Attach\El Poder' > 'c:\apps\MailBox\Attach\Word1.doc' > 'c:\apps\MailBox\Attach\Word2.doc' > 'c:\apps\MailBox\Attach\Word3.doc' > 'c:\apps\MailBox\Attach\Word4.doc' > 'c:\apps\MailBox\Attach\Word5.doc' > > I need to change them to > c:\apps\Sever1\MailBox\Attach\Word1.doc' > c:\apps\Sever1\MailBox\Attach\Word2.doc' > c:\apps\Sever1\MailBox\Attach\Word3.doc' > c:\apps\Sever1\MailBox\Attach\Word4.doc' > > Again its a lot of documents. I update each one indivually I need to > update all > > > > > *** Sent via Developersdex http://www.developersdex.com *** UPDATE SomeTable
SET address1 = REPLACE(address1,'c:\apps\MailBox\Attach\','c:\apps\Sever1\MailBox\Attach\') WHERE address1 like 'c:\apps\MailBox\Attach\%' While you can do the replace thing like a few other suggest (and will need
to for now,) there are really two problems here that you could solve with normalization to make this easy: 1st, instead of one column to hold the whole path, break it up into multiple columns, perhaps the path and the filename: Path: 'c:\apps\MailBox\Attach\' Filename: various per row Then, based on this statement: > Again its a lot of documents. I update each one indivually I need to It seems to me that you have some reason why you are storing all of these > update all files in the same place. If so, then you should pull the path out of the row and move to another related table: FileType ======= FileType: MailAttachment Path: 'c:\apps\MailBox\Attach\' Files ======= FileType: MailAttachment Filename: Now your problem is a snap. To get the file and path, just do a join. It might not be as simple as this, but usage will be much easier and cleaner for future changes. -- Show quote---------------------------------------------------------------------------- Louis Davidson - http://spaces.msn.com/members/drsql/ SQL Server MVP "Arguments are to be avoided: they are always vulgar and often convincing." (Oscar Wilde) "Sean John" <s*@aol.com> wrote in message news:eisIgpsHGHA.2896@TK2MSFTNGP09.phx.gbl... > I'm sorry the path may different documents such as > > I have a lot of documents that are in this location > > c:\apps\MailBox\Attach\ > > and need them all switched to this location > > > c:\apps\Sever1\MailBox\Attach\ > > example > 'c:\apps\MailBox\Attach\El Poder' > 'c:\apps\MailBox\Attach\Word1.doc' > 'c:\apps\MailBox\Attach\Word2.doc' > 'c:\apps\MailBox\Attach\Word3.doc' > 'c:\apps\MailBox\Attach\Word4.doc' > 'c:\apps\MailBox\Attach\Word5.doc' > > I need to change them to > c:\apps\Sever1\MailBox\Attach\Word1.doc' > c:\apps\Sever1\MailBox\Attach\Word2.doc' > c:\apps\Sever1\MailBox\Attach\Word3.doc' > c:\apps\Sever1\MailBox\Attach\Word4.doc' > > Again its a lot of documents. I update each one indivually I need to > update all > > > > > *** Sent via Developersdex http://www.developersdex.com *** |
|||||||||||||||||||||||