I have 3 conditions here. 1. To read only 9 characters of LotNo.(it may consist up to 10 characters) 2. Omit dot if the last(9th) character is dot(.) 3. But some LotNo have less than 9 characters and we need to remove dot if the last character is a (.)
I'm using If else statement in the stored procedure. I used Substring to get the 1st 9 characters. The result looks good for the 1st two condition but it's not working for the 3rd condition.
DECLARE @ShortWaferLotNo VARCHAR(50) set @ShortWaferLotNo = SUBSTRING(@WaferLotNo, 0, 10); if RIGHT(@ShortWaferLotNo, 1) = '.' begin set @ShortWaferLotNo = SUBSTRING(@WaferLotNo, 0, 9); end else if RIGHT(@ShortWaferLotNo, 1) = '.' begin set @ShortWaferLotNo = STUFF(@WaferLotNo,DATALENGTH(@WaferLotNo), 1, '') end else begin set @ShortWaferLotNo='' end
PPLT2.01.B.B.B ( WaferLotNo) -->PPLT2.01 ( read only 1st 9 character and omit dot if the 9th character is a dot.
PQ1H3.1. ----> PQ1H3.1 ( Omit last dot)
PQ1H. ---->PQ1H. (Omit the last dot)
Aucun commentaire:
Enregistrer un commentaire