Tuesday, September 17, 2013

how Remove certain character at Front and back of a varchar

how Remove certain character at Front and back of a varchar

I have a customer data such as below Table= Customer field= CardNo
Data in CardNo
%ABC?;9991?
%ABC?;99912?
%ABC?;999123?
%ABC?;888123?
However i want remove all the "%ABC?;" at the front and "?" at the back,
in the entire Cardno Field. How i do it ? I have try LEFT and RIGHT and
LEN method, seen not working good. UPDATE Customer SET cardno =
RIGHT(cardno, LEN(cardno) - 7)
"Return Error Msg 536, Level 16, State 2, Line 1 Invalid length parameter
passed to the RIGHT function. The statement has been terminated."
Is there any method? thanks a lot

No comments:

Post a Comment