标签:
本身就已经选中,现在去除选中状态,并且要在数据库删除记录
本身没有选中,现在选中,并且在数据库增加记录
set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go --exec deleteSignLog 110, ‘3|4‘ ALTER proc [dbo].[deleteSignLog] @lngArcId int, --文章内码 @lstUserIds nvarchar(max) --选择的用户内码 3|4 as set nocount on select arc_id, sign_time, sign_content, sign_manager_id, status into #Temp01 from dt_sign_log where arc_id = @lngArcId select a into #Temp from dbo.split(@lstUserIds,‘|‘) delete from dt_sign_log where arc_id = @lngArcId insert into dt_sign_log select @lngArcId, isnull(b.sign_time,getdate()), isnull(b.sign_content,‘‘), a.a, isnull(b.status,0) from #Temp a left join #Temp01 b on b.arc_id = @lngArcId and b.sign_manager_id = a.a drop table #Temp drop table #Temp01
SQL函数
set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go ALTER function [dbo].[split](@SourceSql varchar(8000),@StrSeprate varchar(10)) returns @temp table(a varchar(100)) as begin declare @i int set @SourceSql=rtrim(ltrim(@SourceSql)) set @i=charindex(@StrSeprate,@SourceSql) while @i>=1 begin insert @temp values(left(@SourceSql,@i-1)) set @SourceSql=substring(@SourceSql,@i+1,len(@SourceSql)-@i) set @i=charindex(@StrSeprate,@SourceSql) end if @SourceSql<>‘\‘ insert @temp values(@SourceSql) return end
#region 执行一条存储过程 删除sign_logo中的记录 public static void deleteSign_Log(int arc_id, string userss) { using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString)) { conn.Open(); try { SqlCommand comm = new SqlCommand("deleteSignLog", conn); comm.Parameters.Add(new SqlParameter("@lngArcId", SqlDbType.Int)).Value = arc_id; comm.Parameters.Add(new SqlParameter("@lstUserIds", SqlDbType.NVarChar, 1000)).Value = userss; comm.CommandType = CommandType.StoredProcedure; comm.ExecuteNonQuery(); conn.Close(); conn.Dispose(); comm.Dispose(); } catch { } } } #endregion
标签:
原文地址:http://www.cnblogs.com/qigege/p/5104994.html