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
Showing posts with label rest. Show all posts
Showing posts with label rest. Show all posts
Friday, March 9, 2012
Wednesday, March 7, 2012
repair corrupt database?
Hi,
How can I repair a corrupt database? The situation is that I
have the first 2.8gig of a 3.3gb database, the rest couldn't be read
because of a faulty hard drive.
I have the actual backup, and the .mdf file, but both would hold
the same amount of data.
Any help please?
ThanksAssuming the db is suspect and you are indeed performing regular log backups:
Do a log backup using the NO_TRUNCATE option, then restore the latest clean db backup and all
subsequent log backups.
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as ugroup=microsoft.public.sqlserver
"jekZ" <jekz@.nospam.com> wrote in message news:NxmdnV8LEsanSeeiU-KYuQ@.is.co.za...
> Hi,
> How can I repair a corrupt database? The situation is that I
> have the first 2.8gig of a 3.3gb database, the rest couldn't be read
> because of a faulty hard drive.
> I have the actual backup, and the .mdf file, but both would hold
> the same amount of data.
> Any help please?
> Thanks
>
How can I repair a corrupt database? The situation is that I
have the first 2.8gig of a 3.3gb database, the rest couldn't be read
because of a faulty hard drive.
I have the actual backup, and the .mdf file, but both would hold
the same amount of data.
Any help please?
ThanksAssuming the db is suspect and you are indeed performing regular log backups:
Do a log backup using the NO_TRUNCATE option, then restore the latest clean db backup and all
subsequent log backups.
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as ugroup=microsoft.public.sqlserver
"jekZ" <jekz@.nospam.com> wrote in message news:NxmdnV8LEsanSeeiU-KYuQ@.is.co.za...
> Hi,
> How can I repair a corrupt database? The situation is that I
> have the first 2.8gig of a 3.3gb database, the rest couldn't be read
> because of a faulty hard drive.
> I have the actual backup, and the .mdf file, but both would hold
> the same amount of data.
> Any help please?
> Thanks
>
Subscribe to:
Posts (Atom)