Answers

Question and Answer:

  Home  MS SQL Server

⟩ How to Create a View with Data from Multiple Tables?

Can You Create a View with Data from Multiple Tables? The answer is yes. A view can be created with a SELECT statement to join data from multiple tables.

It is a common practice to normalize data into multiple tables. Then using a view to de-normalize them into a single output.

The tutorial exercise below shows you how to create a view to normalize data from two tables SalesOrderHeader and Customer in the sample database AdventureWorksLT.

USE AdventureWorksLT;

GO

CREATE VIEW SalesOrderView AS

SELECT o.SalesOrderNumber, o.OrderDate, o.TotalDue,

c.FirstName, c.LastName, c.CompanyName

FROM SalesLT.SalesOrderHeader o, SalesLT.Customer c

WHERE o.CustomerID = c.CustomerID

GO

 130 views

More Questions for you: