create table.docx

1
CREATE TABLE #ProductosResumen ( idProducto int NOT NULL PRIMARY KEY, nombre varchar(75) NULL, precio smallmoney NULL ); Insertando datos en la tabla temporal global. INSERT #ProductosResumen (idProducto, nombre , precio) SELECT id,nombre, precio FROM dbo.DEMO_PRODUCTO ORDER BY nombre; INSERT INTO repres (numemp, oficinarep, nombrerep) SELECT numemp, oficina, nombre FROM empleados WHERE titulo = 'rep ventas' USE AdventureWorks; GO SELECT c.FirstName, c.LastName, e.Title, a.AddressLine1, a.City, sp.Name AS [State/Province], a.PostalCode INTO dbo.EmployeeAddresses FROM Person.Contact AS c JOIN HumanResources.Employee AS e ON e.ContactID = c.ContactID JOIN HumanResources.EmployeeAddress AS ea ON ea.EmployeeID = e.EmployeeID JOIN Person.Address AS a on a.AddressID = ea.AddressID JOIN Person.StateProvince as sp ON sp.StateProvinceID = a.StateProvinceID; GO

Upload: jorge-gonzales-castillo

Post on 16-Sep-2015

213 views

Category:

Documents


1 download

TRANSCRIPT

CREATE TABLE #ProductosResumen( idProducto int NOT NULL PRIMARY KEY, nombre varchar(75) NULL, precio smallmoney NULL);Insertando datos en la tabla temporal global.INSERT #ProductosResumen (idProducto, nombre , precio)SELECT id,nombre, precio FROM dbo.DEMO_PRODUCTOORDER BY nombre;INSERT INTO repres (numemp, oficinarep, nombrerep) SELECT numemp, oficina, nombre FROM empleados WHERE titulo = 'rep ventas'

USE AdventureWorks;GOSELECT c.FirstName, c.LastName, e.Title, a.AddressLine1, a.City, sp.Name AS [State/Province], a.PostalCodeINTO dbo.EmployeeAddressesFROM Person.Contact AS cJOIN HumanResources.Employee AS e ON e.ContactID = c.ContactIDJOIN HumanResources.EmployeeAddress AS ea ON ea.EmployeeID = e.EmployeeIDJOIN Person.Address AS a on a.AddressID = ea.AddressIDJOIN Person.StateProvince as sp ON sp.StateProvinceID = a.StateProvinceID;GO