Ver Mensaje Individual
  #6 (permalink)  
Antiguo 31/10/2012, 16:00
Avatar de Libras
Libras
Colaborador
 
Fecha de Ingreso: agosto-2006
Ubicación: En la hermosa perla de occidente
Mensajes: 7.412
Antigüedad: 17 años, 8 meses
Puntos: 774
Respuesta: Consulta not exists

Código SQL:
Ver original
  1. CREATE TABLE #temp
  2. (
  3. nombre VARCHAR(200)
  4. )
  5.  
  6. CREATE TABLE #temp2
  7. (
  8. nombre VARCHAR(200)
  9. )
  10.  
  11. INSERT INTO #temp VALUES ('Empleado 1')
  12. INSERT INTO #temp VALUES ('Empleado 2')
  13. INSERT INTO #temp VALUES ('Empleado 3')
  14. INSERT INTO #temp VALUES ('Empleado 4')
  15. INSERT INTO #temp VALUES ('Empleado 5')
  16.  
  17.  
  18. INSERT INTO #temp2 VALUES ('Empleado 1')
  19. INSERT INTO #temp2 VALUES ('Empleado 2')
  20. INSERT INTO #temp2 VALUES ('Empleado 3')
  21.  
  22. SELECT * FROM #temp AS t1
  23. WHERE NOT EXISTS (SELECT nombre FROM #temp2 AS t2 WHERE t1.nombre=t2.nombre)
__________________
What does an execution plan say to t-sql query? Go f**k yourself, if you are not happy with me