dbWriter SQL STORED PROCEDURE SPLIT ON CHARACTER
This SQL stored procedure splits an input from a checkbox input
Request.Form("cbox") on any character.
Such as a comma delimited string. Use this procedure to delete
multiple ID's from a table with one call.
Change the DELETE table line to the code you need run on your table.
CREATE PROCEDURE [DBO].[ZP_YOUR_PROC_SPLIT]
@List VARCHAR(300)
AS
BEGIN
DECLARE @SplitOn varchar (5)
DECLARE @ID int
Set @SplitOn = ','
While (Charindex(@SplitOn,@List)>0)
Begin
SET @ID = ltrim(rtrim(Substring(@List,1,Charindex(@SplitOn,@List)-1)))
--put your code here to run on each ID --DELETE tbl_YOURTABLE where YOUR_ID = @ID
SET @List = Substring(@List,Charindex(@SplitOn,@List)+len(@SplitOn),len(@List))
End
-- this is the last ID in the list for your code to run
on
DELETE tbl_YOURTABLE where YOUR_ID = ltrim(rtrim(@List))
RETURN 0
END
GO
|
|