You are on page 1of 6

-- Primero crear la base de datos onlineshop

-- CREATE DATABASE onlineshop;


USE onlineshop;
-- Creando la tabla de libros electrnicos
CREATE TABLE ebook(
id_book bigint primary key identity,
isbn nvarchar(30) not null,
title nvarchar(150) not null,
pages smallint not null,
price decimal(6,2) not null
);
-- Creando la tabla de pases.
CREATE TABLE country(
id_country int primary key identity,
name nvarchar(45) not null
);
-- Creando la tabla de clientes
CREATE TABLE customer(
id_customer bigint primary key identity,
name nvarchar(25) not null,
surname nvarchar(50) not null,
id_country int not null FOREIGN KEY REFERENCES country(id_country)
);
-- Creando la tabla de tarjetas de crdito.
CREATE TABLE creditCard(
id_credit_card int primary key identity,
name_card nvarchar(20) not null
);
-- Creando la tabla de ordenes.
CREATE TABLE purchaseOrder(
id_purchase_order bigint primary key identity,
date_created datetime not null,
id_customer bigint not null FOREIGN KEY REFERENCES customer(id_customer),
id_book bigint not null FOREIGN KEY REFERENCES ebook(id_book),
id_credit_card int not null FOREIGN KEY REFERENCES creditCard(id_credit_card),
quantity smallint not null,
unit_price decimal(6,2) not null,
total_due decimal(7,2) not null
);
-- Insertando registros a la tabla paises.
INSERT INTO country (name) VALUES
('Per'),('Ecuador'),('Argentina'),('Chile'),('Brasil'),('Uruguay'),
('Paraguay'),('Colombia'),('Mxico'),('Estados Unidos'),('Espaa'),('Italia'),
('Costa Rica'),('Nicaragua'),('Inglaterra'),('Francia'),('Blgica'),('Bolivia'),
('Panam');
-- Insertando registros a la tabla tarjetas de crdito

INSERT INTO creditCard (name_card) VALUES


('Visa'),('Mastercard'),('American Express');
-- Insertando registros a la tabla de libros electrnicos.
INSERT INTO ebook(isbn,title,pages,price) VALUES
('978-1783987313','Web Development with MongoDB and Node JS',294,55.00),
('978-1784397753','Learning Puppet Security',192,35.29),
('978-1512214567','The Hacker Playbook 2',358,105.99),
('978-1449360726','Functional JavaScript',260,36.59),
('978-1783284139','Mastering Clojure Data Analysis',350,80.99),
('978-1783283439','PHPUnit Essentials',324,99.50),
('978-1849516501','RabbitMQ Cookbook',288,69.00),
('978-1783287673','Getting Started with Phalcon',138,79.50),
('978-1783980529','ElasticSearch Server, 2nd Edition',428,85.99),
('978-1783982141','Kali Linux Network Scanning Cookbook',400,59.55),
('978-1449369330','Client-Server Web Apps with JavaScript and Java',260,49.99),
('978-1849695428','Responsive Web Design by Example',338,55.99),
('978-1784393557','Learning iOS 8 Game Development',369,48.50),
('978-1782178125','Developing RESTful Services with JAX-RS 2.0, WebSockets, and
JSON',128,29.69),
('978-0128018675','Hacking Web Intelligence',300,37.59),
('B00U47EHEE','Data Structures and Algorithms',50,29.99),
('978-1784393946','Build Your Own PaaS with Docker',129,35.25),
('978-3319141770','Smart Information Systems',372,68.50),
('978-1784391003','Mastering Entity Framework',304,72.95),
('978-1466592612','Web Security',544,95.99),
('978-1118908662','Python Projects',384,95.85),
('978-1118739495','Beginning Java Programming: The Object-Oriented Approach',672
,105.95),
('978-1118969144','Beginning Software Engineering',480,158.99);
-- INSERTANDO REGISTROS A LA TABLA CLIENTES
INSERT INTO customer (name,surname,id_country) VALUES ('Michael','Zamudio Castil
lo', 9),('Silvia','Baccani Aguirre', 8);
INSERT INTO customer (name,surname,id_country) VALUES ('Carlos','Vsquez Valencia'
, 19),('Corina','Zouza Vidal', 8),('Elena','Miranda Aguirre', 11),('Sebastin','Ay
ala Alvarado', 15),('Jal','Chaparro Maldonado', 8),('William','Ortega Alvarado',
12),('Michael','Bachini Figueroa', 3),('Martha','Toledo Nokawa', 19),('Hiro','Or
tiz Jara', 8),('Tutti','Orellana Herrera', 10),('Tutti','Jara Vergara', 11),('El
ena','Taihushi Barboza', 3),('Francisco','Cruz Fuentes', 13),('Joany','Tan Vera'
, 4),('Silvia','Miranda Aguirre', 13),('Silvia','Pereyra Alvez', 17),('Steve','Q
uiroga Vsquez', 16),('Facundo','Zouza Taihushi', 6),('Franchesca','Babbi Quiroga'
, 5),('Martha','Vargas Rojas', 2),('Fidel','Lind Baccani', 15),('Phil','Vera San
tos', 16),('Franchesca','Garrido Herrera', 18),('Joao','Pereyra Garca', 3),('Edua
rdo','Rivera Castillo', 14),('Facundo','Ferreyra Baiochi', 12),('Miguel','Almeid
a Lind', 13),('Adriana','Rojas Valenzuela', 19),('Jeanpier','Jordan Gmez', 10),('
Mike','Garrido Fitchman', 5),('Mary','Babbi Meza', 1),('Andrs','Sand Sand', 11),(
'Felipe','Vera Chaparro', 4),('Loli','Figueroa Baccani', 5),('Andrs','Rivera Orte
ga', 8),('Andrs','Fitchman Vera', 1),('Mary','Villalta Brown', 17),('Amanda','Pin
o Vargas', 3),('Martha','Zamudio Taihushi', 19),('Luis','Garrido Vargas', 16),('
Saori','Ortiz Ayala', 3),('Fernanda','Anderson Bachini', 10),('Facundo','Maldona
do Muoz', 6),('Rouse','Almeida Nokawa', 12),('Francisco','Vsquez Arias', 6),('Feli
pe','Herrera Taihushi', 6),('Martha','Anguizola Vsquez', 7),('Facundo','Guerrero
Baiochi', 12),('Phil','Fitchman Guerrero', 1),('William','Montenegro Barboza', 7
),('Jeanpier','Jordan Anderson', 13),('Omar','Arias Jara', 11),('Loli','Quiroga
Brown', 18),('Steve','Alvez Reyes', 5),('Miguel','Chaparro Barboza', 11),('Hiro'
,'Rivera Aguirre', 7),('Facundo','Lago Pereyra', 14),('Fidel','Ortiz Ayala', 13)
,('Mitt','Castillo Vsquez', 9),('Corina','Aguirre Santos', 12),('Saori','Baiochi

Vsquez', 3),('Adriana','Herrera Figueroa', 10),('Mike','Herrera Sand', 9),('Micha


el','Castillo Nokawa', 10),('Elena','Valencia Castro', 9),('Omar','Gmez Rojas', 5
),('Joan','Vergara Anguizola', 13),('Fernanda','Bachini Mego', 19),('Sebastin','R
ojas Castro', 10),('Hiro','Garca Arias', 7),('Pamela','Mego Ponce', 17),('George'
,'Alvez Montenegro', 13),('Arturo','Castillo Vargas', 14),('Joao','Gmez Lago', 6)
,('Mike','Mendoza Figueroa', 6),('Steve','Montenegro Castillo', 5),('Yesenia','V
ergara Pereyra', 19),('Mary','Flores Vera', 3),('Jessica','Jara Anderson', 11),(
'Eduardo','Smith Ortega', 7),('Saori','Chaparro Smith', 5),('Andrs','Babbi Anguiz
ola', 15),('Facundo','Tan Fuentes', 4),('Pamela','Valencia Fitchman', 1),('Agustn
','Chavez Rivera', 6),('Mitchell','Lind Valencia', 3),('Rouse','Smith Arias', 18
),('Joany','Jara Pereyra', 7),('Joany','Quiroga Chavez', 15),('George','Orellana
Quiroga', 11),('Mike','Fuentes Anderson', 17),('Arturo','Sand Rivera', 7),('Joa
n','Ayala Nokawa', 4);
-- INSERTANDO REGISTROS A LA TABLA ORDENES DE PEDIDO
INSERT INTO purchaseOrder (date_created,id_customer,id_book,id_credit_card,quant
ity,unit_price,total_due) VALUES (convert(datetime, '2015-06-19 20:39:18', 120),
38, 7, 1,3,0,0),(convert(datetime, '2015-06-26 00:45:12', 120),54, 3, 3,2,0,0);
INSERT INTO purchaseOrder (date_created,id_customer,id_book,id_credit_card,quant
ity,unit_price,total_due) VALUES (convert(datetime, '2015-06-19 12:15:59', 120),
51, 7, 1,6,0,0),(convert(datetime, '2015-06-22 13:24:51', 120),94, 11, 1,2,0,0),
(convert(datetime, '2015-06-07 18:07:46', 120),31, 19, 3,3,0,0),(convert(datetim
e, '2015-06-16 17:12:05', 120),67, 5, 3,2,0,0),(convert(datetime, '2015-06-27 23
:35:47', 120),55, 11, 2,3,0,0),(convert(datetime, '2015-06-08 15:08:22', 120),85
, 4, 1,5,0,0),(convert(datetime, '2015-06-23 12:01:42', 120),75, 22, 1,2,0,0),(c
onvert(datetime, '2015-06-08 14:48:55', 120),10, 1, 3,5,0,0),(convert(datetime,
'2015-06-21 17:45:07', 120),29, 3, 3,1,0,0),(convert(datetime, '2015-06-23 12:50
:20', 120),30, 6, 2,4,0,0),(convert(datetime, '2015-06-21 07:34:29', 120),35, 10
, 2,3,0,0),(convert(datetime, '2015-06-12 12:34:31', 120),46, 1, 1,1,0,0),(conve
rt(datetime, '2015-06-14 15:08:14', 120),69, 10, 1,1,0,0),(convert(datetime, '20
15-06-07 21:15:07', 120),85, 7, 2,4,0,0),(convert(datetime, '2015-06-16 04:13:43
', 120),90, 15, 3,1,0,0),(convert(datetime, '2015-06-17 07:31:13', 120),86, 20,
1,6,0,0),(convert(datetime, '2015-06-22 00:14:46', 120),21, 10, 1,2,0,0),(conver
t(datetime, '2015-06-17 22:31:18', 120),77, 17, 3,3,0,0),(convert(datetime, '201
5-06-19 17:15:59', 120),77, 3, 1,6,0,0),(convert(datetime, '2015-06-02 16:28:52'
, 120),77, 14, 2,1,0,0),(convert(datetime, '2015-06-20 02:11:21', 120),48, 1, 2,
4,0,0),(convert(datetime, '2015-06-25 06:07:44', 120),11, 16, 1,3,0,0),(convert(
datetime, '2015-06-09 07:21:11', 120),33, 2, 3,4,0,0),(convert(datetime, '2015-0
6-05 18:11:58', 120),42, 21, 3,4,0,0),(convert(datetime, '2015-06-08 04:52:28',
120),1, 19, 3,2,0,0),(convert(datetime, '2015-06-12 18:46:49', 120),3, 16, 1,6,0
,0),(convert(datetime, '2015-06-15 11:10:18', 120),11, 12, 3,2,0,0),(convert(dat
etime, '2015-06-14 02:33:54', 120),75, 17, 2,2,0,0),(convert(datetime, '2015-0628 05:51:58', 120),35, 22, 3,1,0,0),(convert(datetime, '2015-06-05 15:12:36', 12
0),33, 11, 2,6,0,0),(convert(datetime, '2015-06-13 11:42:28', 120),51, 23, 3,2,0
,0),(convert(datetime, '2015-06-20 03:03:25', 120),17, 16, 3,3,0,0),(convert(dat
etime, '2015-06-03 18:05:55', 120),54, 19, 2,3,0,0),(convert(datetime, '2015-0618 08:22:13', 120),12, 16, 3,5,0,0),(convert(datetime, '2015-06-16 22:09:05', 12
0),39, 5, 1,6,0,0),(convert(datetime, '2015-06-07 15:09:22', 120),18, 18, 3,1,0,
0),(convert(datetime, '2015-06-05 07:35:14', 120),70, 6, 2,4,0,0),(convert(datet
ime, '2015-06-10 09:04:04', 120),62, 18, 2,3,0,0),(convert(datetime, '2015-06-29
14:12:07', 120),7, 7, 3,1,0,0),(convert(datetime, '2015-06-07 16:52:46', 120),4
3, 18, 1,3,0,0),(convert(datetime, '2015-06-09 22:27:07', 120),48, 15, 3,3,0,0),
(convert(datetime, '2015-06-08 09:49:31', 120),82, 12, 3,2,0,0),(convert(datetim
e, '2015-06-10 17:06:08', 120),15, 4, 1,5,0,0),(convert(datetime, '2015-06-03 22
:38:21', 120),21, 16, 3,3,0,0),(convert(datetime, '2015-06-27 05:28:55', 120),42
, 19, 1,5,0,0),(convert(datetime, '2015-06-18 14:36:05', 120),22, 10, 3,4,0,0),(
convert(datetime, '2015-06-15 17:07:45', 120),63, 23, 1,4,0,0),(convert(datetime
, '2015-06-10 09:35:14', 120),31, 2, 3,3,0,0),(convert(datetime, '2015-06-26 21:
35:52', 120),55, 11, 2,2,0,0),(convert(datetime, '2015-06-18 12:44:59', 120),6,

4, 2,1,0,0),(convert(datetime, '2015-06-26 00:41:41', 120),28, 23, 1,1,0,0),(con


vert(datetime, '2015-06-06 03:21:56', 120),66, 23, 1,6,0,0),(convert(datetime, '
2015-06-20 21:10:22', 120),44, 8, 2,5,0,0),(convert(datetime, '2015-06-10 23:12:
07', 120),61, 20, 1,5,0,0),(convert(datetime, '2015-06-20 03:31:19', 120),71, 19
, 2,6,0,0),(convert(datetime, '2015-06-22 06:22:39', 120),37, 12, 3,6,0,0),(conv
ert(datetime, '2015-06-05 16:11:04', 120),75, 2, 1,2,0,0),(convert(datetime, '20
15-06-28 04:58:10', 120),31, 14, 3,4,0,0),(convert(datetime, '2015-06-19 16:39:2
6', 120),95, 3, 3,1,0,0),(convert(datetime, '2015-06-07 06:06:46', 120),36, 16,
1,4,0,0),(convert(datetime, '2015-06-30 01:16:02', 120),92, 10, 2,3,0,0),(conver
t(datetime, '2015-06-06 19:36:42', 120),3, 9, 2,5,0,0),(convert(datetime, '201506-26 00:08:14', 120),41, 12, 3,6,0,0),(convert(datetime, '2015-06-05 03:20:54',
120),15, 2, 2,1,0,0),(convert(datetime, '2015-06-20 05:21:25', 120),1, 2, 2,1,0
,0),(convert(datetime, '2015-06-29 20:42:38', 120),37, 13, 1,4,0,0),(convert(dat
etime, '2015-06-18 04:19:01', 120),25, 9, 1,6,0,0),(convert(datetime, '2015-06-2
6 13:41:40', 120),53, 16, 3,3,0,0),(convert(datetime, '2015-06-16 15:35:31', 120
),64, 8, 1,1,0,0),(convert(datetime, '2015-06-25 03:51:14', 120),84, 17, 3,6,0,0
),(convert(datetime, '2015-06-27 19:01:43', 120),47, 18, 2,5,0,0),(convert(datet
ime, '2015-06-10 07:14:36', 120),30, 13, 3,6,0,0),(convert(datetime, '2015-06-03
23:36:52', 120),54, 12, 1,3,0,0),(convert(datetime, '2015-06-01 19:36:53', 120)
,85, 3, 2,1,0,0),(convert(datetime, '2015-06-16 18:18:15', 120),63, 19, 1,6,0,0)
,(convert(datetime, '2015-06-21 20:20:44', 120),92, 14, 1,2,0,0),(convert(dateti
me, '2015-06-17 05:04:28', 120),56, 23, 2,2,0,0),(convert(datetime, '2015-06-01
06:24:09', 120),74, 15, 2,1,0,0),(convert(datetime, '2015-06-25 15:30:31', 120),
73, 15, 1,6,0,0),(convert(datetime, '2015-06-04 01:14:30', 120),22, 23, 3,2,0,0)
,(convert(datetime, '2015-06-29 20:15:47', 120),69, 7, 1,3,0,0),(convert(datetim
e, '2015-06-18 12:05:20', 120),74, 13, 1,3,0,0),(convert(datetime, '2015-06-28 0
7:31:35', 120),85, 8, 1,2,0,0),(convert(datetime, '2015-06-01 08:22:11', 120),85
, 12, 1,2,0,0),(convert(datetime, '2015-06-26 04:32:55', 120),65, 14, 3,2,0,0),(
convert(datetime, '2015-06-14 07:33:15', 120),86, 23, 3,3,0,0),(convert(datetime
, '2015-06-04 14:24:23', 120),47, 15, 2,2,0,0),(convert(datetime, '2015-06-03 10
:37:30', 120),7, 23, 2,3,0,0),(convert(datetime, '2015-06-02 07:05:39', 120),22,
9, 3,2,0,0),(convert(datetime, '2015-06-14 09:29:24', 120),28, 14, 2,2,0,0),(co
nvert(datetime, '2015-06-27 05:16:10', 120),77, 6, 3,5,0,0),(convert(datetime, '
2015-06-14 03:16:36', 120),16, 13, 1,6,0,0),(convert(datetime, '2015-06-26 10:11
:02', 120),9, 6, 1,2,0,0),(convert(datetime, '2015-06-07 09:10:58', 120),16, 22,
1,6,0,0),(convert(datetime, '2015-06-17 01:34:43', 120),94, 18, 2,6,0,0),(conve
rt(datetime, '2015-06-15 10:16:44', 120),85, 2, 3,2,0,0),(convert(datetime, '201
5-06-12 13:29:36', 120),74, 4, 3,2,0,0),(convert(datetime, '2015-06-13 20:58:32'
, 120),43, 8, 1,2,0,0),(convert(datetime, '2015-06-06 17:32:01', 120),89, 8, 3,1
,0,0),(convert(datetime, '2015-07-03 20:42:51', 120),65, 3, 1,3,0,0),(convert(da
tetime, '2015-07-23 20:19:50', 120),5, 12, 3,4,0,0),(convert(datetime, '2015-0728 22:13:28', 120),73, 13, 2,5,0,0),(convert(datetime, '2015-07-12 09:20:09', 12
0),6, 13, 3,4,0,0),(convert(datetime, '2015-07-28 16:08:50', 120),22, 23, 2,3,0,
0),(convert(datetime, '2015-07-08 01:48:29', 120),87, 17, 3,1,0,0),(convert(date
time, '2015-07-28 12:24:48', 120),78, 1, 1,4,0,0),(convert(datetime, '2015-07-17
04:21:50', 120),13, 17, 2,2,0,0),(convert(datetime, '2015-07-03 08:17:44', 120)
,25, 15, 3,4,0,0),(convert(datetime, '2015-07-05 21:05:09', 120),50, 10, 3,4,0,0
),(convert(datetime, '2015-07-23 13:41:12', 120),51, 11, 1,2,0,0),(convert(datet
ime, '2015-07-23 23:35:42', 120),10, 15, 1,4,0,0),(convert(datetime, '2015-07-17
20:18:52', 120),95, 20, 3,2,0,0),(convert(datetime, '2015-07-13 06:56:22', 120)
,43, 22, 2,6,0,0),(convert(datetime, '2015-07-22 13:11:28', 120),62, 23, 1,3,0,0
),(convert(datetime, '2015-07-06 04:48:51', 120),52, 5, 1,2,0,0),(convert(dateti
me, '2015-07-17 00:30:25', 120),64, 22, 1,2,0,0),(convert(datetime, '2015-07-27
14:10:09', 120),83, 6, 1,1,0,0),(convert(datetime, '2015-07-16 22:28:07', 120),6
9, 2, 2,2,0,0),(convert(datetime, '2015-07-16 10:53:54', 120),13, 13, 2,1,0,0),(
convert(datetime, '2015-07-26 23:08:08', 120),32, 13, 2,2,0,0),(convert(datetime
, '2015-07-05 06:41:08', 120),91, 6, 1,3,0,0),(convert(datetime, '2015-07-09 03:
01:43', 120),35, 20, 2,5,0,0),(convert(datetime, '2015-07-30 02:04:03', 120),28,
1, 1,4,0,0),(convert(datetime, '2015-07-05 03:11:19', 120),1, 9, 3,1,0,0),(conv
ert(datetime, '2015-07-01 22:45:45', 120),17, 3, 1,2,0,0),(convert(datetime, '20

15-07-05 04:50:59', 120),36, 18, 3,6,0,0),(convert(datetime, '2015-07-12 18:06:4


5', 120),56, 7, 1,2,0,0),(convert(datetime, '2015-07-25 02:19:08', 120),78, 19,
3,2,0,0),(convert(datetime, '2015-07-13 03:48:46', 120),38, 15, 2,5,0,0),(conver
t(datetime, '2015-07-14 14:25:47', 120),4, 5, 1,5,0,0),(convert(datetime, '201507-23 09:47:42', 120),19, 15, 2,1,0,0),(convert(datetime, '2015-07-22 20:14:45',
120),18, 15, 1,5,0,0),(convert(datetime, '2015-07-26 03:19:35', 120),77, 13, 1,
1,0,0),(convert(datetime, '2015-07-01 15:57:13', 120),10, 6, 1,4,0,0),(convert(d
atetime, '2015-07-06 07:42:24', 120),49, 8, 3,6,0,0),(convert(datetime, '2015-07
-20 12:27:40', 120),36, 20, 3,1,0,0),(convert(datetime, '2015-07-01 03:18:35', 1
20),83, 11, 3,2,0,0),(convert(datetime, '2015-07-24 15:15:44', 120),14, 22, 1,5,
0,0),(convert(datetime, '2015-07-08 23:27:57', 120),16, 21, 1,1,0,0),(convert(da
tetime, '2015-07-18 08:25:40', 120),68, 1, 1,3,0,0),(convert(datetime, '2015-0726 21:47:29', 120),75, 15, 1,5,0,0),(convert(datetime, '2015-07-20 08:50:01', 12
0),83, 22, 2,3,0,0),(convert(datetime, '2015-07-10 16:31:52', 120),61, 16, 2,5,0
,0),(convert(datetime, '2015-07-25 17:34:18', 120),54, 20, 1,5,0,0),(convert(dat
etime, '2015-07-01 11:21:25', 120),38, 14, 2,5,0,0),(convert(datetime, '2015-0725 14:01:31', 120),43, 15, 1,1,0,0),(convert(datetime, '2015-07-06 14:07:28', 12
0),5, 1, 2,4,0,0),(convert(datetime, '2015-07-30 01:26:43', 120),36, 12, 3,3,0,0
),(convert(datetime, '2015-07-27 20:54:51', 120),58, 20, 1,5,0,0),(convert(datet
ime, '2015-07-20 10:37:40', 120),62, 12, 1,4,0,0),(convert(datetime, '2015-07-25
04:45:24', 120),61, 21, 1,1,0,0),(convert(datetime, '2015-07-13 11:50:47', 120)
,63, 18, 2,3,0,0),(convert(datetime, '2015-07-16 23:24:41', 120),24, 8, 1,2,0,0)
,(convert(datetime, '2015-07-25 17:52:58', 120),5, 17, 3,1,0,0),(convert(datetim
e, '2015-07-18 18:25:25', 120),92, 4, 3,5,0,0),(convert(datetime, '2015-07-07 06
:23:04', 120),3, 15, 2,4,0,0),(convert(datetime, '2015-07-28 07:57:36', 120),31,
13, 1,6,0,0),(convert(datetime, '2015-07-09 11:02:23', 120),68, 18, 3,5,0,0),(c
onvert(datetime, '2015-07-26 13:14:49', 120),9, 7, 3,1,0,0),(convert(datetime, '
2015-07-27 10:47:40', 120),82, 21, 3,6,0,0),(convert(datetime, '2015-07-04 15:33
:24', 120),34, 2, 1,6,0,0),(convert(datetime, '2015-07-12 17:37:12', 120),11, 6,
3,1,0,0),(convert(datetime, '2015-07-10 10:14:01', 120),61, 16, 3,1,0,0),(conve
rt(datetime, '2015-07-15 12:40:40', 120),35, 5, 3,3,0,0),(convert(datetime, '201
5-07-21 18:03:20', 120),50, 2, 3,5,0,0),(convert(datetime, '2015-07-25 21:56:56'
, 120),58, 7, 1,1,0,0),(convert(datetime, '2015-07-25 06:54:42', 120),18, 11, 1,
3,0,0),(convert(datetime, '2015-07-18 04:06:01', 120),89, 14, 1,5,0,0),(convert(
datetime, '2015-07-17 14:47:33', 120),26, 9, 2,1,0,0),(convert(datetime, '2015-0
7-26 15:55:34', 120),30, 13, 2,3,0,0),(convert(datetime, '2015-07-11 11:42:43',
120),81, 13, 1,3,0,0),(convert(datetime, '2015-07-26 23:30:23', 120),11, 15, 1,5
,0,0),(convert(datetime, '2015-07-10 23:48:14', 120),64, 9, 3,1,0,0),(convert(da
tetime, '2015-07-17 00:21:11', 120),2, 10, 3,2,0,0),(convert(datetime, '2015-0729 05:22:34', 120),62, 1, 3,1,0,0),(convert(datetime, '2015-07-12 17:03:24', 120
),46, 12, 1,6,0,0),(convert(datetime, '2015-07-13 19:52:18', 120),87, 17, 2,5,0,
0),(convert(datetime, '2015-07-27 15:27:31', 120),90, 11, 1,4,0,0),(convert(date
time, '2015-07-16 04:14:24', 120),94, 2, 1,6,0,0),(convert(datetime, '2015-07-29
19:40:52', 120),77, 4, 1,5,0,0),(convert(datetime, '2015-07-17 19:43:07', 120),
87, 20, 2,3,0,0),(convert(datetime, '2015-07-18 00:53:43', 120),16, 23, 1,5,0,0)
,(convert(datetime, '2015-07-21 13:35:13', 120),52, 3, 1,5,0,0),(convert(datetim
e, '2015-07-10 12:58:28', 120),37, 18, 3,3,0,0),(convert(datetime, '2015-07-04 0
6:10:18', 120),95, 19, 1,3,0,0),(convert(datetime, '2015-07-19 23:48:12', 120),9
2, 10, 2,5,0,0),(convert(datetime, '2015-07-26 23:12:48', 120),71, 23, 1,5,0,0),
(convert(datetime, '2015-07-08 15:58:11', 120),38, 14, 1,3,0,0),(convert(datetim
e, '2015-07-23 02:40:07', 120),14, 4, 2,3,0,0),(convert(datetime, '2015-07-11 03
:47:22', 120),46, 10, 1,5,0,0),(convert(datetime, '2015-07-23 02:25:17', 120),72
, 3, 3,4,0,0),(convert(datetime, '2015-07-02 00:53:51', 120),86, 2, 1,6,0,0),(co
nvert(datetime, '2015-07-14 19:27:32', 120),40, 9, 1,1,0,0),(convert(datetime, '
2015-07-16 04:04:22', 120),34, 5, 3,3,0,0);
--Actualizando precios unitarios.
update purchaseOrder
set unit_price=e.price
from ebook e

WHERE purchaseOrder.id_book=e.id_book;
--Actualizando total due
update purchaseOrder
set total_due=unit_price*quantity;

You might also like