MS SQL Server Views - The Koch Family
The Koch Family The Koch Family

Latest news

جاري التحميل ...

MS SQL Server Views

"Creates a virtual table whose contents (columns and rows) are defined by a query. Use this statement to create a view of the data in one or more tables in the database. For example, a view can be used for the following purposes:

- To focus, simplify, and customize the perception each user has of the database.
- As a security mechanism by allowing users to access data through the view, without granting the users permissions to directly access the underlying base tables.
- To provide a backward compatible interface to emulate a table whose schema has changed." [1]

Beside that, our team used view in order to improve the performance of our web apps when a database has a very complicated relationship between its tables by using ORM Frameworks such as Hibernate.

Example code:
--create
CREATE VIEW placeholders
AS
SELECT EMPKEY AS empkey, CONNUMB AS connumb, EMPNBR AS empNbr, ACEEMPN AS empFirstName, ACEEMPFN AS empLastName, EMPNAM AS empFullName,
EMPSIGN AS empSign, AECSALUT AS empSalutation, AECTITLE AS empTitle
FROM dbo.HRMAEC

--update
ALTER VIEW placeholders AS
SELECT EMPKEY AS empkey, CONNUMB AS connumb, EMPNBR AS empNbr, ACEEMPN AS empFirstName, ACEEMPFN AS empLastName, EMPNAM AS empFullName1,
EMPSIGN AS empSign, AECSALUT AS empSalutation, AECTITLE AS empTitle,AECEMAIL As empEmail
FROM HRMAEC


-- drop
DROP VIEW placeholders

--select
SELECT * FROM placeholders
WHERE empkey = 1 AND connumb = 1


Reference:
[1]. https://msdn.microsoft.com/en-us/library/ms187956.aspx

Comments



If you like the content of our blog, we hope to stay in constant communication, just enter your email to subscribe to the blog's express mail to receive new blog updates, and you can send a message by clicking on the button next ...

إتصل بنا

About the site

author The Koch Family <<  Welcome! I'm so glad that you stopped by Your Modern Family blog. Together, we will talk about raising kids, organizing the home and saving money! and Tips & tricks and more…

< Learn more ←

Blog stats

Sparkline 2513183

All Copyrights Reserved

The Koch Family

2020