Pages

Sunday, August 11, 2013

How to Replace the Text in a Database Table Using SQL Enterprise Manager

Enterprise Manager is a great tool provided with Microsoft SQL Server installs. Many companies run multiple SQL Server databases and Enterprise Manager allows you to manage them all from a single interface. Once you open a specific database from within Enterprise Manager, it functions the same as working on an individual database from within the SQL Server interface. To replace text you will write an update query as you would any other SQL-compliant database.

Instructions

    1

    Start SQL Server Enterprise Manager. Expand the objects in the left window by clicking on the plus sign until you have expanded the database you need to replace text in under "Databases." Expand the database and click on the "Tables" icon. Find the table in the right window you want to replace text in and right-click on it. Select "Open Table" from the menu and then "Query."

    In the window in the middle there are the beginnings of a "Select" query. You will replace this with your "Update" query.

    2

    Replace the phrase "Select * From" with "Update." Place your cursor after the name of the table and press "Enter." The next line is where you enter your replacement text. The syntax is:

    Set fieldname = "new text"

    Replace "fieldname" with the actual fieldname you want to change and "new text" with the replacement text. Press "Enter" again and type in your selection criteria on which records to change. The syntax for this is:

    where fieldname = "old text"

    Once again, replace "fieldname" with the actual fieldname and "old text" with the old text you are replacing. The entire query could look something like this.

    Update Contacts set LastName = "Smith" where LastName = "Jones"

    3

    Click on the red exclamation point in the toolbar to run the query. There are no results shown in an update query. You will need to open the table or run a "Select" query to see your changes.

0 comments:

Post a Comment