II.3.4. Assigning a Data Type

After you've identified the appropriate data type, you probably wonder how you actually request to use it. Here are two examples of choosing a data type when creating or modifying a table. If you're interested in this topic in more detail, peek at Chapter 4 of this mini-book.

First, the SQL Server Management Studio is a great tool that you can use to create and maintain your database and associated objects. Here's how to use it to create a new table and set a column's data type:

  1. Launch the SQL Server Management Studio.

  2. Connect to the appropriate SQL Server instance.

  3. Expand the connection's entry in the Object Explorer view.

  4. Expand the Databases folder.

  5. Right-click the Tables folder and choose New Table.

That's all there is to it. You now see a dialog box that allows you to start entering details about your table. Here's how to select a data type:

  1. For each column in your table, enter a unique name.

  2. Choose from one of the data types shown in the drop-down box.

  3. When you've finished itemizing your new columns, save the table.

Figure 3-4 displays the dialog box. The user-defined data type of SALARY uses the underlying MONEY data type.

Figure II.3-4. Selecting a data type in the SQL Server Management Studio.

Second, if character-based utilities are more your style, you can use the SQLCMD utility to create and maintain your tables, setting data types in the process. ...

Get Microsoft® SQL Server™ 2008 All-In-One Desk Reference For Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.