我有一個存儲過程,它可以接收10個參數類型日期... 但我可以顯示信息時諮詢有空,因爲必須顯示所有客戶端信息的流動諮詢......有時客戶有creditnotes訂單,但在次只能有一個訂單,但沒有信用票據.. 我這樣做的WHERE子句:如果在哪裏SQL Server
WHERE
(Customer.cd_CustomerID = ISNULL(@customer, Customer.cd_CustomerID))
AND (@orderID IS NULL OR Orders.cd_OrderID = @orderID)
AND (@Location IS NULL OR CustomerSL.cd_LocID = @Location)
and (Convert(date,Orders.fh_Date,111) BETWEEN coalesce (@FechaPedido1,'1900-01-01') AND coalesce (@FechaPedido2,'3000-12-31'))
and (Convert(date,Receipt.fh_Date,111) BETWEEN coalesce (@FechaRemision1,'1900-01-01') AND coalesce (@FechaRemision2,'3000-12-31'))
and (Convert(date,Invoice.fh_Date,111) BETWEEN coalesce (@FechaFactura1,'1900-01-01') AND coalesce (@FechaFactura2,'3000-12-31'))
and (Convert(date,CreditNote.fh_Date,111) BETWEEN coalesce (@FechaNotaCredito1,'1900-01-01') AND coalesce (@FechaNotaCredito2,'3000-12-31'))
and (Convert(date,Dispersion.fc_CreatedDate,111) BETWEEN coalesce (@FechaDispersion1,'1900-01-01') AND coalesce (@FechaDispersion2,'3000-12-31'))
但在這case..only顯示信息,其中包含客戶的所有流程......諮詢人員不會告訴我沒有訂單的流程沒有緩解或分散情況o無論如何...... allready嘗試使用IF在Where .. bu TI有一些問題sintaxis ...
如果(@ fechapedido1爲null) 開始 (轉換(日期,Orders.fh_Date,111)@之間FechaPedido1和@ FechaPedido2)
結束
sql server showme this message'語法靠近關鍵字'Convert'。' 但...這行是正確的..:■請幫助我:d 感謝 :d
是什麼日期中的「111」是否轉換?這看起來像將日期轉換爲nvarchar的語法...嘗試刪除它。 –
「,111」指定格式,很好 – mCasamento