日期:2014-05-18 浏览次数:20386 次
CREATE PROCEDURE [Contrast_Capital_Ordering] @Basic_Code_Re_Last int, @Basic_Code_Re int AS BEGIN select * into #A from Ordering_Data where Basic_Code_Re=@Basic_Code_Re_Last ------A表为上次 select * into #B from Ordering_Data where Basic_Code_Re=@Basic_Code_Re -------B表为本次 select ISNULL(#A.Price_Code,#B.Price_Code) 编码, ISNULL(#A.Yellow_Num,0) 上次黄, ISNULL(#B.Green_Num,0)本次绿, ISNULL(#A.Yellow_Date,null) 上次黄日期, ISNULL(#B.Green_Date,null) 本次绿日期 from #A full join #B on #A.Price_Code = #B.Price_Code RETURN END
public string Contarst(int Basic_Code_Re_Last, int Basic_Code_Re, out DataSet result)//对比存储过程 { DataSet ds = new DataSet(); a.open(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "Contrast_Capital_Ordering"; //存储过程名 cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = a.connstr; SqlParameter[] parameters ={ new SqlParameter("@Basic_Code_Re_Last",SqlDbType.Int,4), new SqlParameter("@Basic_Code_Re",SqlDbType.Int,4), }; parameters[0].Value = Basic_Code_Re_Last;//上次订单号. parameters[1].Value = Basic_Code_Re;//本次订单号 foreach (SqlParameter p in parameters) { cmd.Parameters.Add(p); } SqlDataAdapter rs = new SqlDataAdapter(cmd); rs.Fill(ds); a.close(); return ds; }
exec Contrast_Capital_Ordering 1234,3456
------解决方案--------------------