Ver Mensaje Individual
  #5 (permalink)  
Antiguo 06/11/2013, 15:58
Avatar de adryan310
adryan310
 
Fecha de Ingreso: septiembre-2012
Mensajes: 450
Antigüedad: 12 años, 3 meses
Puntos: 3
Exclamación Respuesta: Procedimiento almacenado con errores ayudita

Amigo...
Ahora este es mi procedimiento almacenado...
Cita:
CREATE PROCEDURE [dbo].[spTABLE_TEMPORARY_PLAYER]
@Player VARCHAR(10),
@Name VARCHAR(50),
@LastName VARCHAR(50),
@Email VARCHAR(50),
@Password VARCHAR(50),
@Phone VARCHAR(50),
@Zip VARCHAR(50),
@Status CHAR(1),
@LoginDateStart VARCHAR(25),
@LoginDateEnd VARCHAR(25),
@Ip VARCHAR(15),
@WebSite INT,
@Success CHAR(1)
AS
BEGIN
IF OBJECT_ID('tempDB..#PlayerTemp','U') IS NOT NULL
DROP TABLE #PlayerTemp;


DECLARE @StatusAux VARCHAR
DECLARE @WebsiteAux VARCHAR
DECLARE @SuccessAux CHAR(1)

IF @Status <> ''
SET @StatusAux = 'AND Status = ' + @Status
ELSE
SET @StatusAux = ''

SELECT IdPlayer, Player, Name, LastName, Email, Password, IdBook
INTO #PlayerTemp
FROM PLAYER
WHERE Player LIKE @Player AND Name LIKE @Name AND LastName LIKE @LastName AND
Email LIKE @Email AND Password LIKE @Password AND Phone LIKE @Phone AND
Zip LIKE @Zip + '' + @StatusAux

IF @WebSite <> 0
SET @WebsiteAux = 'AND B.[id] = ' + @WebSite
ELSE
SET @WebsiteAux = ''

IF @Success <> 'Y' AND @Success <> 'N'
SET @SuccessAux = ''
ELSE
SET @SuccessAux = ' AND L.[success] = '+ @Success

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 [BackOffice_Dev].[dbo].[login] L, [dbo].[#PlayerTemp] P, BOOK D, [BackOffice_Dev].[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,(@LoginDateStart))
AND L.[login_date] <= convert(datetime,(@LoginDateEnd))
AND L.[ip_address] LIKE @Ip + @WebsiteAux + @SuccessAux
ORDER BY L.[login_date] DESC

END
Pero al parecer los if no me quieren funcionar por que la consulta no me arroja datos y si deberia !