Ver Mensaje Individual
  #2 (permalink)  
Antiguo 16/06/2014, 14:40
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, 9 meses
Puntos: 774
Respuesta: Problema con estructura de una tabla

no entiendo mucho tu referencia pero puedes hacer esto:

Código SQL:
Ver original
  1. CREATE TABLE #temp
  2. (
  3. dato1 VARCHAR(20),
  4. dato2 VARCHAR(20),
  5. dato3 VARCHAR(20)
  6. )
  7.  
  8. INSERT INTO #temp VALUES ('a001','hb','C256')
  9. INSERT INTO #temp VALUES ('a001','gf','u752')
  10. INSERT INTO #temp VALUES ('t856','re','w963')
  11. INSERT INTO #temp VALUES ('c256','oj','a001')
  12. INSERT INTO #temp VALUES ('w785','er','l459')
  13. INSERT INTO #temp VALUES ('w459','ux','t856')
  14.  
  15. SELECT t1.dato1,t1.dato2,t2.dato2,t2.dato1 FROM #temp AS t1
  16. LEFT JOIN #temp AS t2 ON (t1.dato3=t2.dato1)
  17. WHERE t2.dato2 IS NOT NULL

saludos!
__________________
What does an execution plan say to t-sql query? Go f**k yourself, if you are not happy with me