By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,574 Members | 1,968 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,574 IT Pros & Developers. It's quick & easy.

Reversing string concatenation

P: n/a
Hi,

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

Apr 5 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Try this
UPDATE ace
SET picture = Replace(Picture,'\\SHWETABH\Shwetabh\I\' , '')

Markus

Apr 5 '06 #2

P: n/a
Also try

UPDATE ace
SET picture = Substring(Picture,1,charindex('-',Picture,1)-1)

Madhivanan

Apr 5 '06 #3

P: n/a
das
Or 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)

Apr 5 '06 #4

P: n/a
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?

Shwetabh

Apr 6 '06 #5

P: n/a
On 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
Apr 6 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.