Quickly find and rename SQL objects

Transcript

Hello, and welcome to this video presentation in which we’ll introduce different ways of finding SQL objects in a SQL Server database and safely rename them using tools from ApexSQL Fundamentals Toolkit for SQL Server pack without typing a single line of code.

To find SQL objects in a SQL Server database, two tools from the ApexSQL Fundamentals Toolkit for SQL Server pack can be used.

The first tool is ApexSQL Complete, and its Go to objects feature. This feature can be used to perform a quick and fast way to find and locate an object in Object Explorer.

To initiate the Go to object feature, two ways can be used.

In Object Explorer, select a database and from ApexSQL toolbar, click the Go to object button:

Go to object feature from ApexSQL toolbar

Or use the Ctrl+Alt+Y keyboard shortcut.

Once the Go to object window appears, in the Search box, type a name or part of the name of the object that you want to find.

In the search list, all objects that match the typed word will be displayed in the Search box and, at the bottom of the window, the number of the found objects will be shown:

Go to object feature

Additionally, a search scope can be narrowed down with the object type criteria, for example, table type:

Filter SQL objects

Now, in the search list, only tables will be displayed and only those that match the search criteria that was typed in the Search box:

Go to object search list

Double-click on the item from the search list, and that object will be located in the Object Explorer panel:

Find objects in Object Explorer using Go to object feature

To perform a more complex SQL object search over one or more databases, the Object search feature from ApexSQL Search add-in can be used.

To initiate this feature, in Object Explorer, right-click on a database, and from the context menu, choose the Object search command. The same command can be initiated from the ApexSQL Search toolbar or ApexSQL Search menu:

Object search command from Object Explorer context menu

The Object search pane will appear:

Object search pane

In the Search text box, enter the search string, and next to the box, on the right side, choose where the search will be performed, in the object name, object body, etc.

Set search rules

Under the Object types drop-down box, you can choose which object types will the search go through:

Object type drop-down list

Under the Database drop-down box, you can choose on which databases the search will be performed:

Server and Database drop-down list

When the search parameters are set, click the Find button. All results will be shown in the results grid:

Object search results grid

To locate the desired object in Object Explorer, in the results grid, use the right-click on that object, and from the context menu, choose the Navigate to object explorer node command:

Find objects in Object Explorer from Object search results grid

Now, when the SQL object is found, to safely rename it without typing any line of code, you can use the Safe rename feature, which can be initiated either from Object Explorer or from ApexSQL Search results grid. Right-click on the object, and from the context menu, choose the Safe rename command:

Initiate the Safe rename feature

The Safe rename window will appear:

Safe rename window

In the New name box, enter a name and click the Preview script button if you want to review the code or the rename sequence:

Safe rename preview script grid

If everything looks good, click the Create script to generate a renaming code in a new query editor:

New query editor with code for renaming database objects

Here, you can additionally review the generated code before you click the Execute button.

Once the renaming is finished, refresh Object Explorer, and the new name will appear for the chosen object.

With the Safe rename feature you can rename tables, columns, views, stored procedures, functions, parameters without breaking any dependencies.

Thanks for watching. For more information please visit www.apexsql.com