CodeIgniter SQLServer Temp Table不起作用

I want create start date to end date with Temp table.

The SQL is working fine on SQL Server.

But the SQL on CodeIgniter is not working and no result.

the SQL query result_array is array();

IF OBJECT_ID('tempdb..#DATE_LIST_1') IS NOT NULL
DROP TABLE #DATE_LIST_1;

CREATE TABLE #DATE_LIST_1(oc_date date NOT NULL );

INSERT INTO #DATE_LIST_1 (oc_date) VALUES('2015-10-18');
INSERT INTO #DATE_LIST_1 (oc_date) VALUES('2015-10-19');
INSERT INTO #DATE_LIST_1 (oc_date) VALUES('2015-10-20');

SELECT * FROM #DATE_LIST_1;

Not sure if this is will work for the above. But I ran into the exact same issue, what I found was that I had to return the dataset as a result.

so I did the following

$result = $this->db->query($sql)->result();

that returned an array for me which I could then loop over using foreach.

Hope this works for you.