5/13/11

How to Update Syntax on a Microsoft SQL Server

Microsoft Structured Query Language or SQL Server is a database system that lets you store millions of records. The SQL language has an "update" statement that you can use to edit the data in your database tables. You create these update statements in your SQL Server Management Studio console, the main application used to configure and program the SQL Server database.
    • 1

      Click the Windows "Start" button and select "All Programs." Click "SQL Server" in the program groups and click "SQL Server Management Studio." This opens your main programming console.

    • 2

      Click the database name in the left pane. Click the "New Query" button at the top of your console. This opens a SQL editor where you create your update statement.

    • 3

      Type the main update statement syntax. The following code contains the main keywords you need to create the update statement:

      update table

      set column=value

      The "table" is the name of the table that contains your data. The "column" is the column's name and the "value" is assigned to the column.

    • 4

      Set up your "where" clause. The where clause is the filter for your update statement. If you don't use the clause, the entire table updates. Using the where clause, you limit the amount of records updated. For instance, if you want to change all customer last names from "smith" to "Smith" in the database, the following code applies:

      update customer

      set last_name='Smith'

      where last_name='smith'

      This command only changes the records where the customer's last name is "smith."

    • 5

      Press the "F5" key. The F5 key executes the SQL statements. SQL Server returns a message telling you how many database table records were updated.

  • No comments: