Muchas gracias por contestar..ahora vengo de nuevo, hahaha xD
esta es la consulta, pero me dice que ya existe un objeto, donde la tengo que declarar ya intente en varios lugares, pero nada..aqui esta la consulta
Código SQL:
Ver original(
@U INT,
@L INT
)
AS
DECLARE @R INT
SET @L = 1 ---- 1st value
SET @U= 5 ---- Last Value
SELECT @R = ROUND (((@U - @L -1) * RAND() + @L), 0)----Upper to Lower
--SELECT @R----Random Value
--Select 1 - 4 random records
CREATE TABLE #a (id INT, name VARCHAR(50),lastname VARCHAR(50),snumber VARCHAR(50),phone1 VARCHAR(50),phone2 VARCHAR(50),activity INT,suspect INT)
SELECT TOP (ABS(CHECKSUM(NEWID())) % 1 + @R )
id,name,lastname,snumber,phone1,phone2,activity,suspect INTO #a
FROM employments
WHERE
activity=1 AND suspect=0
ORDER BY NEWID()
SELECT * FROM #a
UNION
SELECT id,name,lastname,snumber,phone1,phone2,activity,suspect
FROM employments
WHERE activity=1 AND suspect=1
DROP TABLE #a
Este es el erro..
There is already an object named '#a' in the database.