Logo

Navigation
  • Home
  • Services
    • ERP Solutions
    • Implementation Solutions
    • Support and Maintenance Solutions
    • Custom Solutions
    • Upgrade Solutions
    • Training and Mentoring
    • Web Solutions
    • Production Support
    • Architecture Designing
    • Independent Validation and Testing Services
    • Infrastructure Management
  • Expertise
    • Microsoft Development Expertise
    • Mobile Development
    • SQL Server Database and BI
    • SAP BI, SAP Hana, SAP BO
    • Oracle and BI
    • Oracle RAC
  • Technical Training
    • Learn Data Management
      • Business Intelligence
      • Data Mining
      • Data Modeling
      • Data Warehousing
      • Disaster Recovery
    • Learn Concepts
      • Application Development
      • Client Server
      • Cloud Computing Tutorials
      • Cluster Computing
      • CRM Tutorial
      • EDI Tutorials
      • ERP Tutorials
      • NLP
      • OOPS
      • Concepts
      • SOA Tutorial
      • Supply Chain
      • Technology Trends
      • UML
      • Virtualization
      • Web 2.0
    • Learn Java
      • JavaScript Tutorial
      • JSP Tutorials
      • J2EE
    • Learn Microsoft
      • MSAS
      • ASP.NET
      • ASP.NET 2.0
      • C Sharp
      • MS Project Training
      • Silverlight
      • SQL Server 2005
      • VB.NET 2005
    • Learn Networking
      • Networking
      • Wireless
    • Learn Oracle
      • Oracle 10g
      • PL/SQL
      • Oracle 11g Tutorials
      • Oracle 9i
      • Oracle Apps
    • Learn Programming
      • Ajax Tutorial
      • C Language
      • C++ Tutorials
      • CSS Tutorial
      • CSS3 Tutorial
      • JavaScript Tutorial
      • jQuery Tutorial
      • MainFrame
      • PHP Tutorial
      • VBScript Tutorial
      • XML Tutorial
    • Learn Software Testing
      • Software Testing Types
      • SQA
      • Testing
  • Career Training
    • Career Improvement
      • Career Articles
      • Certification Articles
      • Conflict Management
      • Core Skills
      • Decision Making
      • Entrepreneurship
      • Goal Setting
      • Life Skills
      • Performance Development
      • Personal Excellence
      • Personality Development
      • Problem Solving
      • Relationship Management
      • Self Confidence
      • Self Supervision
      • Social Networking
      • Strategic Planning
      • Time Management
    • Education Help
      • Career Tracks
      • Essay Writing
      • Internship Tips
      • Online Education
      • Scholarships
      • Student Loans
    • Managerial Skills
      • Business Communication
      • Business Networking
      • Facilitator Skills
      • Managing Change
      • Marketing Management
      • Meeting Management
      • Process Management
      • Project Management
      • Project Management Life Cycle
      • Project Management Process
      • Project Risk Management
      • Relationship Management
      • Task Management
      • Team Building
      • Virtual Team Management
    • Essential Life Skills
      • Anger Management
      • Anxiety Management
      • Attitude Development
      • Coaching and Mentoring
      • Emotional Intelligence
      • Stress Management
      • Positive Thinking
    • Communication Skills
      • Conversation Skills
      • Cross Culture Competence
      • English Vocabulary
      • Listening Skills
      • Public Speaking Skills
      • Questioning Skills
    • Soft Skills
      • Assertive Skills
      • Influence Skills
      • Leadership Skills
      • Memory Skills
      • People Skills
      • Presentation Skills
    • Finding a Job
      • Etiquette Tips
      • Group Discussions
      • HR Interviews
      • Interview Notes
      • Job Search Tips
      • Resume Tips
      • Sample Resumes
 

SQL Server 2000: Using Views in SQL Server

By Exforsys | on March 17, 2005 |
SQL Server
This tutorial on Views in SQL Server covers the concept of views, Creating Simple View, deleting views and how to use them.

Using Views in SQL Server

Views are nothing but saved SQL Statements, and are sometimes referred as “Virtual Tables”. Views cannot store data; rather they only refer to data present in tables. As the name implies, they are just used to view the contents of the tables by means of joins etc. They can be used to provide row- or column-level access to data, to wrap up complex joins, to perform complex aggregate queries, and to otherwise customize the display of data.

Creating Simple View

Let’s checkout the basic syntax for creating a view:

CREATE VIEW View_Name;
AS
SELECT Statement
GO

Remember a View can be created only in the current database and can contain at max 1024 columns. Now lets a look creating simple view on “Pubs” database. This is the example database installed when you install SQL Server (Except when you install client tools on Windows XP and then install MSDE)

Create View SimpleView
As
Select emp_id , fname , lname From employee

Now Open your Enterprise Manager, double click the database and then Views, You will see a view named “Simple View”. This is the view which we have created above.

You need to have a goal in mind when creating a view. There are a number of occasions where views are suitable.

  • To hide the complexity of the underlying database schema or customize the data and schema for a set of users.
  • As a Security Tool

Let’s take a look at each of these scenarios.

Hiding Complexity and Customizing Data:

Consider the join below

Create View JoinView
As
Select emp_id , fname , lname , job_desc From employee Inner Join jobs
On employee.job_id = jobs.job_id
Where employee.job_id = 5

This View selects data from two tables by means of an Inner Join. See the result by opening the view in Enterprise Manager.





Now writing such queries are almost impossible for all users. May be some of your users can manage it but majority have to learn SQL in order to view data. Here View comes in action. We just created Views using complex queries and allow our users to view that data. They even don’t think to know the complex structure of the database behind the scene or handling typical queries.



Now writing such queries are almost impossible for all users. May be some of your users can manage it but majority have to learn SQL in order to view data. Here View comes in action. We just created Views using complex queries and allow our users to view that data. They even don’t think to know the complex structure of the database behind the scene or handling typical queries.

View as a Security Tool:

In many cases you don’t want your users to view complete database data for some security reasons and also to restrict a group of users to view data specifically to their use. In this case you just publish Views where you display data only for user’s perspective. All the users have their own view of data in the forms of VIEWS. For e.g. Accounts Users can view data related to Accounts and Finance where as Managements have their own.

Modifying Data through Views:

Insertion in Views is same as Insertion in actual tables. Values Inserting in Views also reflects in the underlying table. But always consider constraints and relationships during insertions in Views specially when they contains more than one table.

Insert into simpleview (emp_id , fname , lname)
values (‘DBT39435M’,’exforsys’,’Member’)

Creating Views on Views:

Yes you can create Views on other Views. The syntax is almost same. Just you need to replace table names with Views names in you SELECT statement.

Dropping Views:

Dropping View is same as dropping any other object from the database.



Here I am first confirming whether the particular view (ViewOnView) is already present in the database. If then I will remove it using DROP keyword.

« « MSAS : The Data warehousing framework of SQL Server 2000 – Part 1
MSAS : The Data warehousing framework of SQL Server 2000 – Part 2 » »

Author Description

Avatar

Editorial Team at Exforsys is a team of IT Consulting and Training team led by Chandra Vennapoosa.

Free Training

RSSSubscribe 394 Followers
  • Popular
  • Recent
  • SQL Server 2000: Using System and Extended Stored Procedures

    March 13, 2005 - 0 Comment
  • SQL Server 2000:Creating and Using Stored Procedures

    March 12, 2005 - 0 Comment
  • SQL Server 2000: Creating Stored Procedure with Input and Output Parameters

    March 12, 2005 - 0 Comment
  • SQL Server 2000 Training Details

    March 11, 2005 - 0 Comment
  • SQL Server 2000: Securing Your Stored Procedure

    March 13, 2005 - 0 Comment
  • SQL Server 2000: Using System and Extended Stored Procedures

    March 13, 2005 - 0 Comment
  • SQL Server 2000: Securing Your Stored Procedure

    March 13, 2005 - 0 Comment
  • SQL Server 2000: Creating Stored Procedure with Input and Output Parameters

    March 12, 2005 - 0 Comment
  • SQL Server 2000:Creating and Using Stored Procedures

    March 12, 2005 - 0 Comment
  • SQL Server 2000 Training Details

    March 11, 2005 - 0 Comment

Exforsys e-Newsletter

ebook
 

Related Articles

  • SQL Server 2000: Using System and Extended Stored Procedures
  • SQL Server 2000: Securing Your Stored Procedure
  • SQL Server 2000: Creating Stored Procedure with Input and Output Parameters
  • SQL Server 2000:Creating and Using Stored Procedures
  • SQL Server 2000 Training Details

Latest Articles

  • Project Management Techniques
  • Product Development Best Practices
  • Importance of Quality Data Management
  • How to Maximize Quality Assurance
  • Utilizing Effective Quality Assurance Strategies
  • Sitemap
  • Privacy Policy
  • DMCA
  • Trademark Information
  • Contact Us
© 2023. All Rights Reserved.IT Training and Consulting
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.AcceptReject Read More
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT