I'm using Laravel 5.6 and I have the following code
$values = [1, "2018-08-10", "2018-08-11"];
$data = DB::select('exec SP_NAME ?, ?', $values);
dump($data);
And this is my stored procedure:
ALTER PROCEDURE [dbo].[SP_NAME]
@Opc int,
@FechaIni nvarchar(20)=null,
@FechaFin nvarchar(20)=null
AS
BEGIN
if @opc=1
begin
SELECT * from table where convert(date, datetimeField) between @FechaIni and @FechaFin
end
END
If I execute my query on MSSQL Server everything works fine. When I execute the SP from Laravel there is no error message, just an empty array.
Testing and playing with the code I found that the problem is when I'm sending more than one parameter, for example I change my select query for this:
SELECT * from table where convert(date, datetimeField) between '2018-08-10' and '2018-08-11'
What could be the problem and how can I solve it?
?