C#sql 自动平 负数归0.00,并计算 把负数的值从库存中扣掉
SqlConnection conn = new SqlConnection("server=2PNT8Q4Y5OJ0DP0\\SQLEXPRESS;uid=sa;pwd=****;database=lijunyaoye2019;Max Pool Size = 512;");
conn.Open();string sql = "update 合并盘点表 set 库存=库存+上月末库存 where 上月末库存 like '%-%' "; // 这里是把负数加到库存数中
string sql1 = "update 合并盘点表 set 上月末库存=0.00 where 上月末库存 like '%-%' "; /// 这里是把负数归零
SqlCommand com = new SqlCommand(sql, conn);
com.ExecuteNonQuery();
SqlCommand com1 = new SqlCommand(sql1, conn);
com1.ExecuteNonQuery();
conn.Close();