--http://lafabricadesoftware.blogspot.com/
DECLARE @tablaUno table(Id_Uno INT IDENTITY,campo varchar(100),campod varchar(100))
DECLARE @tablaDos table(Id_Uno INT IDENTITY,campo varchar(100),campod varchar(100))
DECLARE @tablaTres table(Id_Uno INT IDENTITY,campo varchar(100),campoy varchar(100))
INSERT INTO @tablaUno (campo, campod )
VALUES ('a','b')
INSERT INTO @tablaUno (campo, campod )
VALUES ('c','d')
INSERT INTO @tablaUno (campo, campod )
VALUES ('x','y')
INSERT INTO @tablaDos (campo, campod )
VALUES ('I','I')
INSERT INTO @tablaDos (campo, campod )
VALUES ('I','I')
INSERT INTO @tablaDos (campo, campod )
VALUES ('I','I')
INSERT INTO @tablaTres(campo, campoy )
VALUES ('o','o')
INSERT INTO @tablaTres(campo, campoy)
VALUES ('c','d')
INSERT INTO @tablaTres(campo, campoy)
VALUES ('x','y')
INSERT INTO @tablaTres(campo, campoy)
VALUES ('x','yt')
UPDATE @tablaTres SET campo=tu.campo, campoy=td.campod
FROM @tablaTres te INNER JOIN @TablaUno tu ON te.Id_Uno = tu.id_uno
INNER JOIN @tablaDos td ON td.Id_Uno=tu.id_uno
SELECT * FROM @tablaTres
DECLARE @tablaDos table(Id_Uno INT IDENTITY,campo varchar(100),campod varchar(100))
DECLARE @tablaTres table(Id_Uno INT IDENTITY,campo varchar(100),campoy varchar(100))
INSERT INTO @tablaUno (campo, campod )
VALUES ('a','b')
INSERT INTO @tablaUno (campo, campod )
VALUES ('c','d')
INSERT INTO @tablaUno (campo, campod )
VALUES ('x','y')
INSERT INTO @tablaDos (campo, campod )
VALUES ('I','I')
INSERT INTO @tablaDos (campo, campod )
VALUES ('I','I')
INSERT INTO @tablaDos (campo, campod )
VALUES ('I','I')
INSERT INTO @tablaTres(campo, campoy )
VALUES ('o','o')
INSERT INTO @tablaTres(campo, campoy)
VALUES ('c','d')
INSERT INTO @tablaTres(campo, campoy)
VALUES ('x','y')
INSERT INTO @tablaTres(campo, campoy)
VALUES ('x','yt')
UPDATE @tablaTres SET campo=tu.campo, campoy=td.campod
FROM @tablaTres te INNER JOIN @TablaUno tu ON te.Id_Uno = tu.id_uno
INNER JOIN @tablaDos td ON td.Id_Uno=tu.id_uno
SELECT * FROM @tablaTres
No hay comentarios:
Publicar un comentario