Database Explorer allows you to perform operations on objects using the shortcut menu. Right-click an object in Database Explorer to access commands for specific tasks, such as creating or modifying synonyms, stored procedures, functions, triggers, and sequences.
To create a synonym:
1. In Database Explorer, right-click a synonym or Synonyms node and select New Synonym or Open Editor.
2. In a SQL document that opens, enter the CREATE SYNONYM statement.
3. At the bottom of the SQL document, select Apply Changes to save the synonym.
To edit a synonym:
1. In Database Explorer, right-click the synonym you want to edit and select Open Editor.
2. In a SQL document that opens, edit the synonym.
3. On the SQL toolbar, select Save to save the changes. Alternatively, go to the File menu and select Save or press Ctrl+S.
To delete a synonym:
1. In Database Explorer, right-click the synonym you want to edit and select Delete. Alternatively, press Del.
2. In the Delete Synonym confirmation dialog that opens, select Yes to confirm the deletion.
Note
You cannot undo the drop synonym operation, as it permanently deletes all its data and structure. It is recommended that you back up the database before deleting it. For instructions, see How to back up a SQL Server database.
To create a stored procedure:
1. In Database Explorer, right-click a procedure or Programmability > Procedures node and select New Procedure or Open Editor.
2. In a SQL document that opens, enter the CREATE PROCEDURE statement.
3. At the bottom of the SQL document, select Apply Changes to save the stored procedure.
To edit a stored procedure:
1. In Database Explorer, right-click the stored procedure you want to edit and select Modify via SQL.
2. In a SQL document that opens, edit the stored procedure.
3. On the SQL toolbar, select Save to save the changes. Alternatively, go to the File menu and select Save or press Ctrl+S.
To delete a stored procedure:
1. In Database Explorer, right-click the stored procedure you want to edit and select Delete. Alternatively, press Del.
2. In the Drop Procedure confirmation dialog that opens, select Yes to confirm the deletion.
Note
You cannot undo the drop stored procedure operation, as it permanently deletes all its data and structure. It is recommended that you back up the database before deleting it. For instructions, see How to back up a SQL Server database.
To debug a stored procedure:
1. In Database Explorer, right-click the stored procedure you want to execute and select Execute.
2. In the Edit parameters window that opens, enter the input parameters and select OK. For more information, see Use parameters.
Note
If the stored procedure calls a function or a trigger, in Database Explorer, select Step Into and follow the steps from How to debug a stored procedure.
To create a function:
1. In Database Explorer, right-click a function or Programmability > Functions node and select Open Editor.
2. In a SQL document that opens, enter the CREATE FUNCTION statement.
3. At the bottom of the SQL document, select Apply Changes to save the function.
To create a table-valued function:
1. In Database Explorer, expand the Functions > Table-valued Functions node.
2. Select a function and then select New Table-valued Function.
3. In a SQL document that opens, enter the CREATE FUNCTION statement.
4. At the bottom of the SQL document, select Apply Changes to save the function.
To create a scalar function:
1. In Database Explorer, expand the Functions > Scalar-valued Functions node.
2. Select a function and then select New Scalar Function.
3. In a SQL document that opens, enter the CREATE FUNCTION statement.
4. At the bottom of the SQL document, select Apply Changes to save the function.
To create an aggregate function:
1. In Database Explorer, expand the Functions > Aggregate Functions node.
2. Select a function and then select New Aggregate Function.
3. In a SQL document that opens, enter the CREATE AGGREGATE statement.
4. At the bottom of the SQL document, select Apply Changes to save the function.
To edit a function:
1. In Database Explorer, right-click the function you want to edit and select Modify via SQL.
2. In a SQL document that opens, update the function details.
3. At the bottom of the SQL document, select Apply Changes to save and apply the changes made to the function.
To delete a function:
1. In Database Explorer, right-click the function you want to edit and select Delete. Alternatively, press Del.
2. In the Drop Function confirmation dialog that opens, select Yes to confirm the deletion.
Note
You cannot undo the drop function operation, as it permanently deletes all its data and structure. It is recommended that you back up the database before deleting it. For instructions, see How to back up a SQL Server database.
To debug a function:
1. In Database Explorer, right-click the scalar-valued function you want to debug and select Execute.
2. In the View output parameters window that opens, enter the parameters and select Close. For more information, see Use parameters.
Note
To start debugging a function, in Database Explorer, select Step Into and follow the steps from How to debug a function.
To create a DDL trigger:
1. In Database Explorer, right-click a trigger or Programmability > Database Triggers node and select New DDL Trigger.
2. In a SQL document that opens, enter the CREATE TRIGGER statement.
3. At the bottom of the SQL document, select Apply Changes to save the trigger.
To edit a DDL trigger:
1. In Database Explorer, right-click the DDL trigger you want to edit and select Modify via SQL.
2. In a SQL document that opens, edit the DDL trigger.
3. On the SQL toolbar, select Save to save the changes. Alternatively, go to the File menu and select Save or press Ctrl+S.
To delete a trigger:
1. In Database Explorer, right-click the trigger you want to edit and select Delete. Alternatively, press Del.
2. In the Drop Trigger confirmation dialog that opens, select Yes to confirm the deletion.
Note
You cannot undo the drop trigger operation, as it permanently deletes all its data and structure. It is recommended that you back up the database before deleting it. For instructions, see How to back up a SQL Server database.
To activate a trigger, in Database Explorer, right-click the DDL trigger and select Enable.
To deactivate a trigger, in Database Explorer, right-click the DDL trigger and select Disable.
To turn on all triggers, right-click the Database Triggers node and select Enable All.
To turn off all triggers, right-click the Database Triggers node and select Disable All.
To create a sequence:
1. In Database Explorer, right-click any sequence or Programmability > Sequences node and select New Sequence.
2. In a SQL document that opens, enter the CREATE SEQUENCE statement.
3. At the bottom of the SQL document, select Apply Changes to save the sequence.
To edit a sequence:
1. In Database Explorer, right-click the sequence and select Open Editor.
2. In a SQL document that opens, update the CREATE SEQUENCE statement.
3. At the bottom of the SQL document, select Apply Changes to save the sequence.
To delete a sequence:
1. In Database Explorer, right-click the sequence you want to edit and select Delete. Alternatively, press Del.
2. In the Drop Sequence confirmation dialog that opens, select Yes to confirm the deletion.
Note
You cannot undo the drop sequence operation, as it permanently deletes all its data and structure. It is recommended that you back up the database before deleting it. For instructions, see How to back up a SQL Server database.
The table describes the shortcut commands available when you right-click an object in Database Explorer. The table includes each command description and its availability for different database object types.
| Name | Description | Available for database object types |
|---|---|---|
| Duplicate Object | Opens the Duplicate Object dialog to copy object structure and/or data. | Tables Views Synonyms Procedures Functions Triggers Sequences Assemblies User types Service Broker Storage Security |
| Unit Test > Add New Test | Opens the Add New Test dialog to create a unit test for a specific database. | Procedures |
| Unit Test > View Test List | Opens the Test List Manager to view unit tests in the database. | Procedures |
| Generate Script As | Generates a script of the selected object using the CREATE, DROP, DROP and CREATE, SELECT, INSERT, UPDATE, DELETE, INSERT/UPDATE STORED PROCEDURE statements. The script can be saved to a new SQL document or a file, or copied to the clipboard. Note: The statements to be generated differ based on the selected object type. |
Synonyms Procedures Functions Triggers Sequences Assemblies User types Service Broker Storage Security |
| Send to > Query Builder | Adds the selected table to the Query Builder diagram. | Synonyms |
| Send to > Master Detail Browser | Adds the selected table to the Master Detail Browser document. | Synonyms |
| Send to > Database Diagram | Adds the selected table to a database diagram. | Synonyms Functions |
| Show Details | Opens Object Viewer to view object details. | Synonyms Procedures Functions Triggers Sequences External resources Assemblies User types Service Broker Storage Security |
| Delete | Drops the selected object from the database. Alternatively, press Del. |
Synonyms Procedures Functions Triggers Sequences External resources Assemblies User types Service Broker Storage Security |
| Refresh | Updates the object to reflect the latest changes. Alternatively, press F5. |
Synonyms Procedures Functions Triggers Sequences External resources Assemblies User types Service Broker Storage Security |
| Properties | Opens the Properties pane to view the object information. Alternatively, press F4. |
Synonyms Procedures Functions Triggers Sequences External resources Assemblies User types Service Broker Storage Security |