谁给个存储过程设计  和  代码例子啊~ 学习~~~~~~~~~~~~~~~~~~~~~~~

解决方案 »

  1.   


    CREATE PROCEDURE CustOrdersOrders @CustomerID nchar(5)
    AS
    SELECT OrderID, 
    OrderDate,
    RequiredDate,
    ShippedDate
    FROM Orders
    WHERE CustomerID = @CustomerID
    ORDER BY OrderIDGONorthwind随手抄下来的
      

  2.   

      public DataSet ShowHRConfirm(int emid)
            {
                DataSet ds = new DataSet();
                SqlConnection con = new SqlConnection(conn);
                SqlCommand cmd = con.CreateCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "proc_ShowHRConfirm";
                cmd.Parameters.AddWithValue("@emid",emid);
                SqlDataAdapter dsCommand = new SqlDataAdapter(cmd);
                dsCommand.Fill(ds);
                return ds;
            }
    create proc proc_ShowHRConfirm
    @emid int
    as
    declare @s varchar(20)
    declare @s1 varchar(20)
    select @s=stime ,@s1=ftime from kpicontrol where kpistatus=1
    select * from MonthRecord where emid=@emid and EventDate between @s and @s1 and type=1 and HRConfirm=1GO