Drop Table
Support Forum for database administrators and web based access to important newsgroups related to databasesHi, How can I remove a part of string from complete string in SQL? this is something i want to do: update ace set PICTURE = PICTURE - '\\SHWETABH\Shwetabh \I\' But here ' - ' is not allowed. How can I remove the string \\SHWETABH\Shwetabh\ I\ from the column PICTURE? Regards, Shwetabh
Post Follow-up to this messageTry this UPDATE ace SET picture = Replace(Picture,'\\S HWETABH\Shwetabh\I\' , '') Markus
Post Follow-up to this messageAlso try
UPDATE ace
SET picture = Substring(Picture,1,
charindex('-',Picture,1)-1)
Madhivanan
Post Follow-up to this messageOr if you know that the first part of the string is always going to be 'PICTURE' then simply use this: update ace set PICTURE = left(PICTURE, 7)
Post Follow-up to this messageThanks Marcus, That did the trick. Now there is one more problem. I know to add the string, the query is UPDATE ace SET PICTURE = '\\SHWETABH\Shwetabh \I\' + PICTURE Now this query appends the string before PICTURE column contents. Now is there a way that the contents having the string '\\SHWETABH\Shwetabh \I\' do not get updated with this string and only cells which do not have the string get updated? Shwetabh
Post Follow-up to this messageOn 6 Apr 2006 02:32:02 -0700, Shwetabh wrote: >Thanks Marcus, >That did the trick. > >Now there is one more problem. >I know to add the string, the query is > >UPDATE ace >SET PICTURE = '\\SHWETABH\Shwetabh \I' + PICTURE > >Now this query appends the string before PICTURE column contents. >Now is there a way that the contents having the string > '\\SHWETABH\Shwetabh \I' >do not get updated with this string and only cells which do not have >the string get updated? Hi Shwetabh, UPDATE ace SET PICTURE = '\\SHWETABH\Shwetabh \I' + PICTURE WHERE PICTURE NOT LIKE '\\SHWETABH\Shwetabh \I\%' -- Hugo Kornelis, SQL Server MVP
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread