Tengo el siguiente código donde trato de crear una tabla temporal en sql-server e insertarle los datos que me devuelva un select.
Código PHP:
$sqlTlb = "CREATE TABLE #PlayerTemp(IdPlayer INT, Player VARCHAR(10), Name VARCHAR(50), LastName VARCHAR(50), Email VARCHAR(50), Password VARCHAR(20),
IdBook SMALLINT)
INSERT INTO #PlayerTemp (IdPlayer, Player, Name, LastName, Email, Password, IdBook)
SELECT IdPlayer, Player, Name, LastName, Email, Password, IdBook
FROM PLAYER
WHERE Player LIKE '%P1%' AND Name LIKE '%TEST%' AND LastName LIKE '%TEST%' AND
Email LIKE '%[email protected]%' AND Password LIKE '%.BP888%' AND Phone LIKE '%%' AND
Zip LIKE '%%' AND Status = 'E'";
$this->strData = $this->strConnect->query($sqlTlb);
Código PHP:
$sqlConsult = "SELECT TOP 10000 P.[IdPlayer], P.[Player], L.[username], L.[password], L.[ip_address], L.[login_date], L.[success], D.[Description], B.[host_name],
P.[Name] + ' ' + P.[LastName] AS 'Name', P.Email
FROM [CPW-SQLP105].[BackOffice].[dbo].[login] L, #PlayerTemp P, BOOK D, [CPW-SQLP105].[BackOffice].[dbo].[book] B
WHERE D.[IdBook] = P.[IdBook] AND L.[book_id] = B.[book_id] AND D.[IdBook] = L.[book_id] AND
P.[player] = L.[username] AND B.[id] = L.[website_id] AND
L.[login_date] >= convert(datetime,('2013-01-30 20:10:11')) AND L.[login_date] <= convert(datetime,('2013-11-01 20:10:11'))
AND L.[success] = 'N'";