日期:2014-05-17 浏览次数:20571 次
create procedure pro_DelModelList_sysrole
(
@ListId nvarchar(max) --即上面的id
)
as
begin transaction
declare @error int
declare @sql nvarchar(1000)
set @error = 0
set @sql = 'delete from tb_sys_role where id in ('+@ListId+')' --我想把这条语句中删除要么全部成功要么有一条没删除就全不删除
exec sp_ExecuteSql @sql
set @error = @error+ @@error
if @error <>0
begin
print '有错误,回滚'
rollback transaction
end
else
begin
PRINT '成功'
commit transaction
end
create procedure pro_DelModelList_sysrole
(
@ListId nvarchar(max) --即上面的id
)
as
begin transaction
declare @error int
set @error = 0
delete from tb_sys_role where CHARINDEX(','+cast(id as varchar)+',',','+@ListId+',')>0 --我想把这条语句中删除要么全部成功要么有一条没删除就全不删除
set @error = @error+ @@error
if @error <>0
begin
print '有错误,回滚'
rollback transaction
end
else
begin
PRINT '成功'
commit transaction
end
go