Manage views

This topic describes how to create and manage views from Database Explorer.

Create a view

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

2. In View Designer, specify the view settings:

  • Under Query Text, enter the view name, select the schema it belongs to, enter the query, and select view options.
  • Optional: Under Query Design, build the view query on the diagram.
  • Optional: Under Indexes, add indexes for the view.
  • Optional: Under Statistics, set up statistics.
  • Optional: Under Triggers, add triggers.
  • Optional: Under T-SQL, preview the generated script.

3. In the bottom panel, click Apply Changes to save the view.

Edit a view using View Designer

1. In Database Explorer, right-click the view you want to edit and select Open Editor.

2. In View Designer, update the view settings.

Note

View Designer doesn’t support changing the view schema. This action requires moving the view to a different schema, rather than modifying its structure.

3. In the bottom panel, select Apply Changes to apply the changes.

Edit a view using SQL

1. In Database Explorer, right-click the view you want to edit and select Modify via SQL.

2. In a SQL document, edit the view.

3. On the SQL toolbar, click Save to save the changes.

Alternatively, on the menu bar, select File > Save, or press Ctrl+S.

Delete a view

1. In Database Explorer, right-click the view you want to delete and select Delete, or press Delete.

2. Click Yes to confirm the deletion.

Note

You cannot undo the drop view operation, as this action permanently deletes the view. To avoid data loss, back up the database before deleting the view.

Duplicate a view

1. In Database Explorer, right-click the required view and select Duplicate Object.

2. In the Duplicate Object dialog, configure the object settings:

  • In Destination connection, select the target server.
  • In Destination database, select the target database.
  • In Destination schema, select the target schema.
  • In New object name, enter the object name.
  • Select Drop destination object to drop the destination object if it already exists.
  • Optional: Select Script Changes, then select To New SQL Window to open the generated script in a new SQL document, or To Clipboard to copy it to the clipboard.

3. Click OK.

Manage data

1. In Database Explorer, right-click the view and select Open Data in Editor.

Alternatively, select Open Editor and switch to the Data tab.

2. On the Data tab of View Designer, view the data in the grid.

3. To perform any action on the data, right-click the selected row and select the required command from the shortcut menu.

For more information, see Work with data in Data Editor.

Retrieve data

To retrieve data from the selected view, in Database Explorer, right-click it and select Select All Rows.

Rename a view

1. In Database Explorer, right-click the selected view and select Rename.

2. Specify the new view name, then press Enter.