Skip to content

Instantly share code, notes, and snippets.

@phpleo
Created January 10, 2011 16:58
Show Gist options
  • Save phpleo/773046 to your computer and use it in GitHub Desktop.
Save phpleo/773046 to your computer and use it in GitHub Desktop.
tsql: Creando una tabla temporal y llenandola con registros de una tabla existente
-- Crear tabla temporal con los valores actuales del campo EnEjecucion
-- eliminando si existe
IF OBJECT_ID( N'tempdb..#ProyectoEnejecucionEstado') IS NOT NULL
DROP TABLE #ProyectoEnejecucionEstado;
GO
-- creando la tabla temporal
CREATE TABLE #ProyectoEnejecucionEstado (
CodigoProyecto CHAR(6),
EnEjecucion BIT
);
GO
-- insertando los datos actuales de la tabla proyecto
INSERT INTO #ProyectoEnejecucionEstado(CodigoProyecto, EnEjecucion)
SELECT p.CodigoProyecto, p.EnEjecucion
FROM Proyecto.Proyecto p;
GO
-- comprobando
SELECT * FROM #ProyectoEnejecucionEstado
GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment