Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Truncating Data

Author  Topic 

Phibian
Starting Member

32 Posts

Posted - 2003-03-26 : 12:14:05
I have the following text 'Cell Labour Job Added to Work Order x' stored as a string, where the work order number is variable and nothing else is.

I need to update all fields with that text to become 'Job Added to Work Order x'.

I was thinking a sub string could do what I want, but I'm having trouble using it in the context of the update statement.

Any ideas?

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2003-03-26 : 12:43:55
UPDATE TableX
SET FieldY = RIGHT(FieldY, Len(FieldY)- Len('Cell Labour '))
WHERE PATINDEX('Cell Labour Job Added to Work Order %',FieldY) > 0

Just one of the many ways:
You could also use like for matching
You could find the position of x and concatenate that with your new string.



Go to Top of Page

Phibian
Starting Member

32 Posts

Posted - 2003-03-26 : 13:09:29
Thanks!

I modified the where clause to use a like because it was simpler and then I could also use it on the Access copy of the same database (used for off-site development).


Go to Top of Page

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2003-03-31 : 23:30:30
Consider using MSDE or SQL Developer for off-site it will require less work all you have to transport is a backup or the DDL and DML scripts.



Go to Top of Page
   

- Advertisement -