日期:2014-05-17 浏览次数:20465 次
Declare @Tbl Table (ID int, NAME varchar(50)) Insert Into @Tbl Select 1001, 'CG14*13.5-85/31-37/113*23W' Union All Select 1002, 'CG6.5*5.4-190/31-37/248*33W' Union All Select 1003, 'CG5*5-105/30-32/103.5*10.5V+W' Union All Select 1004, 'CG5*5-105/30-33/103*10.5' Union All Select 1005, 'CG6.5*5.3-125/31-37/104*9.8B(V+W)' Union All Select 1006, 'CG6.5*5.4-190/31-37/114.5*23P' ;With Tbl(ID, Num1, Num2) As( Select ID, CAST(SUBSTRING(SUBSTRING(NAME, CHARINDEX('/', NAME) + 1, 5), 1, 2) As Int) , CAST(SUBSTRING(SUBSTRING(NAME, CHARINDEX('/', NAME) + 1, 5), 4, 2) As Int) From @Tbl ) Update A Set A.Name = A.Name + Case When ABS(B.Num1-B.Num2) > 5 Then '/二' Else '/三' End From @Tbl A Inner Join Tbl B On A.ID = B.ID Select * From @Tbl /* ID NAME ----------- -------------------------------------------------- 1001 CG14*13.5-85/31-37/113*23W/二 1002 CG6.5*5.4-190/31-37/248*33W/二 1003 CG5*5-105/30-32/103.5*10.5V+W/三 1004 CG5*5-105/30-33/103*10.5/三 1005 CG6.5*5.3-125/31-37/104*9.8B(V+W)/二 1006 CG6.5*5.4-190/31-37/114.5*23P/二 */