电脑故障

位置:IT落伍者 >> 电脑故障 >> 浏览文章

存储过程批量删除记录


发布日期:2024/6/19
 

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存储过程就会删除相应的记录

上一篇:append与Highwater测试

下一篇:解决ASM无法启动问题