2016-09-23 55 views
0
create proc splist_of_current_orders (@fromdate nvarchar(50),@todate nvarchar(50)) 
as 
begin 
    SELECT 
     ot.Order_Id, 
     ot.Pay_date, 
     ot.Pay_type, 
     ot.Merchant_Id, 
     t.BusinessName, 
     t.OyospaName, 
     tu.Userfullname, 
     ot.Booked_Date 
    FROM dbo.Tbl_Order_Trans AS ot 
    LEFT OUTER JOIN 
     dbo.Tbl_ServiceCategory AS sc ON sc.ServiceCategoryID = ot.ServiceCategoryID 
    LEFT OUTER JOIN 
     dbo.Tbl_user AS tu ON ot.UserId = tu.UserId 
    LEFT OUTER JOIN 
     dbo.Tbl_Merchant AS t ON ot.Merchant_Id = t.Merchant_Id 

    where ot.Booking_Date BETWEEN @fromdate and @todate 
end 

回答

0

可能會做這樣的

create proc splist_of_current_orders (@fromdate datetime,@todate datetime) 
as 
begin 
SELECT ot.Order_Id, ot.Pay_date, ot.Pay_type, ot.Merchant_Id, t.BusinessName, t.OyospaName, tu.Userfullname, ot.Booked_Date 
FROM   dbo.Tbl_Order_Trans AS ot LEFT OUTER JOIN 
         dbo.Tbl_ServiceCategory AS sc ON sc.ServiceCategoryID = ot.ServiceCategoryID LEFT OUTER JOIN 
         dbo.Tbl_user AS tu ON ot.UserId = tu.UserId LEFT OUTER JOIN 
         dbo.Tbl_Merchant AS t ON ot.Merchant_Id = t.Merchant_Id where convert(date,ot.Booking_Date) BETWEEN convert(date,@fromdate) and convert(date,@todate) 
         end 
相關問題