Views:

Views contain row and column as table contains. The fields in a view are fields from one or more real tables in the database. You can add SQL functions, WHERE, and JOIN statements to a view and present the data as if the data were coming from one single table.

Syntax: Creating Views in SQL server
---- SYNTAX CREATING VIEWS IN SQL SERVER
CREATE VIEW <VIEWNAME>
AS
----DATA SELECT FROM TABLE
---SELECT STATEMENT FOR SELECTING VALUE
Example: Creating view in SQL
---- DEMONSTRATION FOR CREATING VIEWS IN SQL SERVER
CREATE VIEW TESTVIEWCONCEPT
AS
SELECT * FROM userlogininfo
Syntax: Update views
----SYNTAX TO UPDATE VIEW IN SQL SERVER
CREATE OR REPLACE VIEW <VIEW_NAME>
AS
---- SELECT MODIFIED QUERY FROM DATABASE TABLE
Example: Updating Views in SQL server
---- DEMONSTRATION OF UPDATE VIEW IN SQL SERVER
CREATE OR REPLACE VIEW TESTVIEWCONCEPT
AS
SELECT * FROM userlogininfo WHERE UserName LIKE 'AR%'
Syntax: Drop Views from SQL Server

-----DEMONSTRATION TO DROP VIEWS FROM SQL SERVER

DROP VIEW <VIEW_NAME>

Example: Drop Views from SQL server

-----DEMONSTRATION TO DROP VIEWS FROM SQL SERVER

DROP VIEW TESTVIEWCONCEPT

Views with multiple table statement:

Syntax: Creating Views with multiple select query

---- SYNTAX CREATING VIEWS WITH MULTIPLE SELECT STATEMENT IN SQL SERVER
CREATE VIEW <VIEWNAME>
AS
--SELECT FIRST STATEMENT
UNION ALL
--SELECT SECOND STATEMENT
UNION ALL
-- SELECT THIRD STATEMENT
..............
..............
Example: Creating View with multiple select query
---- DEMONSTRATION OF CREATING VIEW WITH MULTIPLE TABLE STATEMENT
CREATE VIEW MULTIVIEW
AS
SELECT * FROM ClientInfo UNION ALL
SELECT * FROM  DUPLICATE


  Modified On Nov-21-2017 01:37:32 AM

Leave Comment