110,536
社区成员
发帖
与我相关
我的任务
分享
sql = string.Format(@"
update {0} set iscw ={2},cwUser=@cwUser,cwTime = getdate()
where id={1} and isApply=0
", TableName, id, iscw, isApply);
//插入新数据
foreach (var item in listSource2)
{
//存在则忽略
string sqlDestination1 = string.Format("select * from basic_org where ORG_ID = {0}", item.Branch_code);
var listDestination1 = destinationConn.Query<basic_orgModel>(sqlDestination1);
string sqlInsert1 = null;
if (listDestination1.Count() == 0)
{
sqlInsert1 = @"insert basic_org(ORG_ID, OPARENT, ORG_NAME, OFLAG, OSTATE, brand_code, brand_name, type_code, type_name)
values(@BRANCH_CODE, ifnull(@DISTRICT_CODE, 1), @BRANCH_NAME, 2, 1, @brand_code, @brand_name, @type_code, @type_name)";
}
else
{
sqlInsert1 = @"update basic_org set OSTATE = (case when @Mark = 0 then 1 else -1 end) where ORG_ID = @Branch_code";
}
destinationConn.Execute(sqlInsert1, item);
addNum++;
}
sql = string.Format(@"
update {0} set iscw ={2},cwUser=@cwUser,cwTime = getdate()
where id={1} and isApply=0
", TableName, id, iscw);
SqlCommand com = new SqlCommand(sql, con);
com.Parameters.Add(new SqlParameter("@cwUser", SqlDbType.NChar)).Value = 给该字段赋的值;
update Records_Moneys set iscw =1,cwUser=@cwUser,cwTime = getdate()
where id=13 and isApply=0
update {0}
这种东西。你需要真正学习一次 t-sql 语言。