我使用的鐵軌控制檯嘗試執行以下存儲過程:不能在軌控制檯(ActiveRecord的 - SQLSERVER適配器)執行存儲過程
exec dbo.MP_RPT_Q_VENTAS_TOP_PRODUCTOS @COD_CTE='',@COD_DOC='T',@FECHA1='2015-01-01',@FECHA2='2015-23-06',@COD_GRUPO='',@COD_ZONA='',@PORCENTAJE=30,@DESCRI='',@MIN='X',@CONTADO='',@COD_AGRICOLA='',@COD_GRUPO_PROD_INTERES='',@UTILIDAD_MAXIMA='101',@CATEGORIA='',@FILTRAR_VALOR='C',@CODIGO_INGREDIENTE_ACTIVO='',@CODIGOS_PRODUCTOS='',@CLASIFICACION='T',@ORDEN='$UTILIDAD',@FORMATO_ASP='0',@CLASIFICACION2='T',@CLASIFICACION3='T',@TIPO_CLIENTE='TODOS',@COD_LOTE=''
要做到這一點,我運行以下命令,注意我條紋的參數和只剩值:
Almacen.execute_procedure("MP_RPT_Q_VENTAS_TOP_PRODUCTOS", '','T','2015-01-01','2015-23-06','','',30,'','X','','','','101','','C','','','T','$UTILIDAD','0','T','T','TODOS','')
當我試圖運行線,我得到以下錯誤:
TinyTds::Error: The conversion of a varchar data type to a smalldatetime data ty
pe resulted in an out-of-range value.: EXEC MP_RPT_Q_VENTAS_TOP_PRODUCTOS '', 'T
', '2015-01-01', '2015-23-06', '', '', 30, '', 'X', '', '', '', '101', '', 'C',
'', '', 'T', '$UTILIDAD', '0', 'T', 'T', 'TODOS', ''
ActiveRecord::StatementInvalid: TinyTds::Error: The conversion of a varchar data
type to a smalldatetime data type resulted in an out-of-range value.: EXEC MP_R
PT_Q_VENTAS_TOP_PRODUCTOS '', 'T', '2015-01-01', '2015-23-06', '', '', 30, '', '
X', '', '', '', '101', '', 'C', '', '', 'T', '$UTILIDAD', '0', 'T', 'T', 'TODOS'
, ''
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/activerecord-sqlserver-adapt
er-4.0.0/lib/active_record/connection_adapters/sqlserver/database_statements.rb:
96:in `each'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/activerecord-sqlserver-adapt
er-4.0.0/lib/active_record/connection_adapters/sqlserver/database_statements.rb:
96:in `block in execute_procedure'
...
我試圖通過改變它們之間的引號來改變這些日期,並且存儲被執行,但沒有結果,這是不正確的。
任何想法?
嘗試不同的日期格式DD-MM- yyyy或mm-dd-yyyy。 '23 -06-2015'vs '06 -23-2015' – lad2025
也檢查[this](http://stackoverflow.com/a/8533023/5070879),你也可以嘗試執行'SET DATEFORMAT ymd' – lad2025
哦,更改爲「2015-06-23」並開始工作。顯然是忽略當前日期時間格式的db(?) –