Other database objects

Last modified: July 8, 2025

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.

Synonyms

Create a synonym

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.

Edit a 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.

Delete a synonym

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.

Stored procedures

Create a stored procedure

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.

Edit a 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.

Delete a stored procedure

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.

Debug a stored procedure

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.

Functions

Create a function

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.

Create a table-valued 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.

Create a scalar 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.

Create an aggregate 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.

Edit a 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.

Delete a 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.

Debug a function

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.

Triggers

Create a DDL trigger

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.

Edit a DDL 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.

Delete a trigger

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.

Activate a DDL trigger

To activate a trigger, in Database Explorer, right-click the DDL trigger and select Enable.

Deactivate a DDL trigger

To deactivate a trigger, in Database Explorer, right-click the DDL trigger and select Disable.

Turn on all triggers

To turn on all triggers, right-click the Database Triggers node and select Enable All.

Turn off all triggers

To turn off all triggers, right-click the Database Triggers node and select Disable All.

Sequences

Create a sequence

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.

Edit a 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.

Delete a 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.

Shortcut menu commands

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. TablesViewsSynonymsProceduresFunctionsTriggersSequencesAssembliesUser typesService BrokerStorageSecurity
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. SynonymsProceduresFunctionsTriggersSequencesAssembliesUser typesService BrokerStorageSecurity
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. SynonymsFunctions
Show Details Opens Object Viewer to view object details. SynonymsProceduresFunctionsTriggersSequencesExternal resourcesAssembliesUser typesService BrokerStorageSecurity
Delete Drops the selected object from the database. Alternatively, press Del. SynonymsProceduresFunctionsTriggersSequencesExternal resourcesAssembliesUser typesService BrokerStorageSecurity
Refresh Updates the object to reflect the latest changes. Alternatively, press F5. SynonymsProceduresFunctionsTriggersSequencesExternal resourcesAssembliesUser typesService BrokerStorageSecurity
Properties Opens the Properties pane to view the object information. Alternatively, press F4. SynonymsProceduresFunctionsTriggersSequencesExternal resourcesAssembliesUser typesService BrokerStorageSecurity