Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Name: DESIDERIO, JEROME MARTIN H

Course/Section: COE182P

1. Using Adventure Work 2016 Database Generate/Create Scripts that will transfer all person
schema including data into new database name AdventurePerson.(Output is SQL command)

select * into AdventurePerson.dbo.Address from


AdventureWorks2016CTP3.Person.Address

(hindi ko na po canopy yung lahat ng command po, bali bawat person schema po
ginayan ko po)

2. What is “Megan E. Burke address” in the adventure work 2016 database? Result set outputted
column should be Fullname and Address including city. (Includes SQL COMMAND SELECT
STATEMENT)

select * from Person.Address where rowguid ='3E2FB5D8-D299-4F33-B24A-


5F70F42694A3';

(wala pong lumabas na data address about kay megan)

3. Which person have a surname “Allen”? Result output should be two column Firstname and
LastName. (Includes SQL COMMAND SELECT STATEMENT)

select FirstName, LastName from Person.Person where LastName = 'Allen';

4. What is “Harold K. Chandra” email address? Result output should be two column name as
Fullname and Email Address. (Includes SQL COMMAND SELECT STATEMENT)

SELECT FirstName,MiddleName, LastName, EmailAddress


FROM AdventurePerson.Person, AdventurePerson.EmailAddress
WHERE LastName = 'Chandra' AND FirstName = 'Harold' AND MiddleName = 'K'

5. What is “Katherine A. Price” CELL PHONENUMBER? Result output should be two column name
as Fullname and phonenumber. (Includes SQL COMMAND SELECT STATEMENT)

SELECT FirstName, LastName, PhoneNumber, MiddleName from


AdventureWorks2016CTP3.Person.Person, AdventureWorks2016CTP3.Person.PersonPhone
where LastName = 'Price' And FirstName = 'Katherine' And MiddleName = 'R';

6. Make a select statement showing all person with OWNER as contact type sort by lastname
descending.
SELECT FirstName,MiddleName, LastName, ContactTypeID
FROM AdventurePerson.Person, AdventurePerson.ContactType
WHERE ContactTypeID = 11
ORDER BY LastName DESC
7. Make a select statement showing all person originated from England as state province sort by
firstname.
SELECT FirstName,StateProvinceID,StateProvinceCode, Name
FROM AdventurePerson.Person, AdventurePerson.StateProvince
WHERE StateProvinceCode = 'ENG'
ORDER BY FirstName

8. Make a SQL select statement showing all person came from country region name AUSTRALIA.
SELECT *FROM Person.Person, Person.CountryRegion WHERE CountryRegionCode = 'AU'

9. CREATE A DATABASE BACKUP SCRIPT NAME AdventurePerson.BAK located at local disk C.


BACKUP DATABASE [ADVENTUREPERSON]
TO DISK = N'C:\Users\Martin\Desktop\DotNET 2\Exam3'
GO

10. CREATE a Restoration script of the database backup AdventurePerson.BAK and store it file into a
new folder name Exam3.
RESTORE DATABASE [ADVENTUREPERSON]
FROM DISK = 'C:\Users\Martin\Desktop\DotNET 2\Exam3\AdventurePerson.bak'
GO

11. Create stored procedure that will create/add new value to table
Demo.DemoSalesOrderHeaderSeed.

ALTER PROCEDURE [dbo].[ Demo.DemoSalesOrderHeaderSeed]


-- Add the parameters for the stored procedure here
@ [CID] int,
@ [SID] int,
@ [BID] int,
@ [ShipTAID] int
@ [ShipMID] int
@ [LID] int

AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here


INSERT INTO Demo.DemoSalesOrderHeaderSeed (CustomerID, SalesPersonID,
BillToAddressID, ShipToAddressID, ShipMethodID, LocalID )
VALUES (@CID, @ SID, @ BID, @ ShipTAID, ShipMID, LID)

12. Create stored procedure that will update/edit value to table


Demo.DemoSalesOrderHeaderSeed.
ALTER PROCEDURE [dbo].[ UpdateDemo.DemoSalesOrderHeaderSeed ]
-- Add the parameters for the stored procedure here
@ [CID] int,
@ [SID] int,
@ [BID] int,
@ [ShipTAID] int
@ [ShipMID] int
@ [LID] int

AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here


UPDATE Demo.DemoSalesOrderHeaderSeed
SET CustomerID = @CID,
SalesPersonID = @SID,
BillToAddressID = @BID,
ShipToAddressID = @ShipTAID,
ShipMethodID=@ ShipMID,
WHERE LocalID = @LID

END
13. Create stored procedure that will remove/delete value to table
Demo.DemoSalesOrderHeaderSeed.
ALTER PROCEDURE [dbo].[ DeleteDemoSalesOrderHeaderSeed]
-- Add the parameters for the stored procedure here
@LID INT
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here


DELETE FROM Person WHERE LocalID = @LID
END
14. Create stored procedure that will select all column in HumanResources.Employee and
HumanResources.Department.
15. Create stored procedure that will select all column in Purchasing. Vendor and
Purchasing.ProductVendor.

You might also like