Drop Table

Support Forum for database administrators and web based access to important newsgroups related to databases
Register on Database Support Forum Edit your profileCalendarFind other Database Support forum membersFrequently Asked QuestionsSearch this forum -> 
For Database admins: Free Database-related Magazines Now Free shipping to Texas


Post New Thread










Thread
Author

Reversing string concatenation
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


Report this thread to moderator Post Follow-up to this message
Old Post
Shwetabh
04-05-06 08:28 AM


Re: Reversing string concatenation
Try this
UPDATE ace
SET picture =  Replace(Picture,'\\S
 HWETABH\Shwetabh\I\'
 , '')

Markus


Report this thread to moderator Post Follow-up to this message
Old Post
m.bohse@quest-consultants.com
04-05-06 08:28 AM


Re: Reversing string concatenation
Also try

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

Madhivanan


Report this thread to moderator Post Follow-up to this message
Old Post
Madhivanan
04-05-06 02:30 PM


Re: Reversing string concatenation
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)


Report this thread to moderator Post Follow-up to this message
Old Post
das
04-05-06 06:37 PM


Re: Reversing string concatenation
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


Report this thread to moderator Post Follow-up to this message
Old Post
Shwetabh
04-06-06 12:33 PM


Re: Reversing string concatenation
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

Report this thread to moderator Post Follow-up to this message
Old Post
Hugo Kornelis
04-07-06 01:26 AM


Sponsored Links





Last Thread Next Thread
Post New Thread

Microsoft SQL Server forum archive

Show a Printable Version Email This Page to Someone! Receive updates to this thread
Microsoft SQL Server
Access database support
PostgreSQL Replication
SQL Server ODBC
FoxPro Support
PostgreSQL pgAdmin
SQL Server Clustering
MySQL ODBC
Web Applications with dBASE
SQL Server CE
MySQL++
Sybase Database Support
MS SQL Full Text Search
PostgreSQL Administration
SQL Anywhere support
DB2 UDB Database
Paradox Database Support
Filemaker Database
Berkley DB
SQL 2000/2000i database
ASE Database
Forum Jump:
All times are GMT. The time now is 08:16 PM.

 
Mobile devices forum | Database support forum archive




Copyrights DropTable.com Database Support Forum 2004 - 2006