我有一个存储过程,它可以接收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