CREATEPROCEDURE GetVertifiedWorkIdByWorkReader @WorkReadervarchar(100) AS Declare@PointerPrevint Declare@PointerCurrint Declare@tempvarchar(10) Set@PointerPrev=1 Set@PointerCurr=1 BEGINTRANSACTION Set NoCount ON Set@PointerCurr=CharIndex(',',@WorkReader,@PointerPrev+1) set@temp=cast(SUBSTRING(@WorkReader,@PointerPrev,@PointerCurr-@PointerPrev) asvarchar) CREATETABLE #temp (WorkId varchar(6), UserName varchar (250),BanCi varchar (10),[Type of work]varchar (10),DepartmentName varchar (50)) INSERTINTO #temp select OperationUser.WorkId,OperationUser.UserName,BanCi.BanCi, gongzhong.[Type of work],OperationDepartment.DepartmentName from OperationUser,gongzhong,BanCi,OperationDepartment where WorkId in (@temp) and gongzhong.gongzhongId=OperationUser.gongzhongId and BanCi.BanCiId=OperationUser.banciId and OperationDepartment.DepartmentId=OperationUser.DepartmentId SET@PointerPrev=@PointerCurr while (@PointerPrev+1<LEN(@WorkReader)) Begin Set@PointerCurr=CharIndex(',',@WorkReader,@PointerPrev+1) if(@PointerCurr>0) Begin set@temp=cast(SUBSTRING(@WorkReader,@PointerPrev+1,@PointerCurr-@PointerPrev-1) asvarchar) INSERTINTO #temp select OperationUser.WorkId,OperationUser.UserName,BanCi.BanCi, gongzhong.[Type of work],OperationDepartment.DepartmentName from OperationUser,gongzhong,BanCi,OperationDepartment where WorkId in (@temp) and gongzhong.gongzhongId=OperationUser.gongzhongId and BanCi.BanCiId=OperationUser.banciId and OperationDepartment.DepartmentId=OperationUser.DepartmentId End else Break End set@temp=cast(SUBSTRING(@WorkReader,@PointerPrev+1,LEN(@WorkReader)-@PointerPrev) asvarchar) INSERTINTO #temp select OperationUser.WorkId,OperationUser.UserName,BanCi.BanCi, gongzhong.[Type of work],OperationDepartment.DepartmentName from OperationUser,gongzhong,BanCi,OperationDepartment where WorkId in (@temp) and gongzhong.gongzhongId=OperationUser.gongzhongId and BanCi.BanCiId=OperationUser.banciId and OperationDepartment.DepartmentId=OperationUser.DepartmentId select*from #temp droptable #temp Set NoCount OFF IF@@error=0 BEGIN COMMITTRANSACTION END ELSE BEGIN ROLLBACKTRANSACTION END GO