Click here to Skip to main content
15,889,877 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello

i need to modify some cells in a sql table

i had cells like this in a colum called description:

10000259 - 10000259 - CATHETER SUCTION 10 FR, WITH FINGER TIP CONTROL DISPOSABLE, STERILE

10000304 - 10000304 - CLIP, HEAMOSTATIC, MEDIUM , TITANIUM, WHITE, SINGLE USE, STERILE


i neeed to delete only the numbers:

CATHETER SUCTION 10 FR, WITH FINGER TIP CONTROL DISPOSABLE, STERILE

CLIP, HEAMOSTATIC, MEDIUM , TITANIUM, WHITE, SINGLE USE, STERILE


i need a funtion becouse i have to modify around 2000, all the numbers in this cells i need to delete had 8 digits.

can someone help me with this
thanks in advance

What I have tried:

update table
 set description = 'CATHETER SUCTION 10 FR, WITH FINGER TIP CONTROL ' where description = '10000259 - 10000259 - CATHETER SUCTION 10 FR, WITH FINGER TIP CONTROL '
Posted
Updated 19-Mar-18 7:05am

1 solution

Since all of the numbers are the same length, something like this should work:
SQL
UPDATE
    Table
SET
    Description = Substring(Description, 23, Len(Description) - 22)
WHERE
    Description Like '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] - [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] - %'
;

LIKE (Transact-SQL) | Microsoft Docs[^]
 
Share this answer
 
Comments
Maciej Los 19-Mar-18 14:12pm    
5ed!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900