Working with Views

A view is a virtual table based on the result-set of an SQL statement. A view contains rows and columns, just like a real table. The fields in a view are fields from one or more real tables in the database.

dbForge Studio for SQL Server allows you to create, modify, and drop views, retrieve and alter data in underlying tables.


In order to start creating a view, you should have the following privileges:

  • CREATE VIEW on the proper database
  • SELECT privilege on the proper tables

Creating a View

  1. In Database Explorer, right-click the Views node and select New View.

  2. Input name of the view and type a query that will represent the view.
  3. Save the document by clicking the Update Database button on the bottom of the window, or the Save button on the Standard toolbar. If there are any errors in the SQL syntax, you will be notified about it.

    CREATE VIEW Syntax

    CREATE VIEW HumanResources.vEmployeeDepartment
       ,d.[Name] AS [Department] 
    FROM [HumanResources].[Employee] e
      INNER JOIN [Person].[Person] p
      ON p.[BusinessEntityID] = e.[BusinessEntityID]
       INNER JOIN [HumanResources].[EmployeeDepartmentHistory] edh 
       ON e.[BusinessEntityID] = edh.[BusinessEntityID] 
       INNER JOIN [HumanResources].[Department] d 
       ON edh.[DepartmentID] = d.[DepartmentID] 
    WHERE edh.EndDate IS NULL

A view always shows up-to-date data! The database engine recreates the data, using the view’s SQL statement, every time a user queries a view.

Creating a View with the Help of Snippet

Editing a View

Edit a view by selecting Edit View from the Database Explorer node shortcut menu. In the opened document, you can alter the query text. Once a view is created, you can not modify its name or owner. Save the document to apply changes you’ve made to the query text.

Dropping a View

Drop a view by selecting Delete from the Database Explorer node shortcut menu.

Retrieving and Modifying View Data

To retrieve view data, right-click a view in Database Explorer, and then click Retrieve Data on the shortcut menu. The data is rendered in grid-based editor. You can browse and edit view data in the same way as you browse and edit table data.

Retrieving View Data

Some views can be non-updatable. You can not edit their data.