CREATE PROCEDURE XTJ_NewsInfor_DeleteArray @ID nvarchar() as DECLARE @PointerPrev int DECLARE @PointerCurr int DECLARE @TId int Set @PointerPrev= while (@PointerPrev < LEN(@ID)) Begin Set @PointerCurr=CharIndex(@ID@PointerPrev) if(@PointerCurr>) Begin set @TId=cast(SUBSTRING(@ID@PointerPrev@PointerCurr@PointerPrev) as int) Delete from XTJ_NewsInfor where ID=@TID SET @PointerPrev = @PointerCurr+ End else Break End 删除最后一个因为最后一个后面没有逗号所以在循环中跳出需另外再删除 set @TId=cast(SUBSTRING(@ID@PointerPrevLEN(@ID)@PointerPrev+) as int) Delete from XTJ_NewsInfor where ID=@TID GO 下来要批量删除记录的话只要给存储过程传参……n存储过程就会删除相应的记录 |