October 31, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Quick Start Guide to SQL Server 7 -- Part 1

  • November 19, 2002
  • By Karl Moore
  • Send Email »
  • More Articles »

The most important objects within your database are tables.

These are a lot like Excel spreadsheets, each storing rows of information, such as a customer order or shipping address.

Typically, you would utilise normalisation rules when creating the tables, meaning you should ensure each table has no repeating columns, utilises primary and foreign keys where appropriate, and so on.

To view the Tables:

  • View your Database in Enterprise Manager (as before)
  • Click the 'Tables' image
    • Any tables displayed beginning with 'sys', as well as 'dtproperties' are SQL Server's own. It uses these tables to store information about your database

To create a Table:

  • View the Tables (as before)
  • Click 'Action' in the toolbar, select 'New Table'
  • Enter a Table Name when prompted
    • You may wish to use a table naming convention here. Many opt for tblTableName, whilst others prefer TableName_t. It's your call
  • Define your fields, row by row
    • Column Name Enter the name of this field. You may wish to use naming conventions here, depending on the data type
    • Datatype Select the required data type (full explanatory list on the next page)
    • Length This isn't always editable. It specifies the length of your data type (eg, char data type, 15 characters in length, or varchar data type, maximum 15 characters in length)
    • Precision Applies to numeric data only. This isn't always editable. Specifies the maximum number of digits in the number (eg, the number 539.154 has a scale of six). Almost a length value for numeric data types
    • Scale Applies to numeric data only. This isn't always changeable. Specifies the maximum number of digits to store to the right of the decimal point (eg, 12.528 has a scale of three)
    • Allow Nulls Check if Null values (ie, nothing) are allowable in this field. Otherwise, uncheck
    • Default Value A default value to be placed into this field when a new row is inserted
    • Identity If this will be an identity column (ie, you want SQL Server to place a unique number into the field), check this box
    • Identity Seed If this is an identity column, enter the starting point for the unique numbers. By default, this is set at one
    • Indentity Increment If this is an identity column, with each new row, the unique ID number will be incremented. Typically, it is upped by one each time. If you wish to change that figure (ie, increase numbers by ten each time), enter the incrementing value here
    • IsRowGuid Check if you want to automatically insert a Globally Unique Identifier (GUID) into this field. These are guaranteed unique IDs and no two in the world should ever be the same. An example of a GUID is {B31C08E5-2A56-11D4-B09E-CFB9E165D54C}. To choose this option, you must have a Data Type of Unique Identifier
  • When finished, press CTRL-F4 to close the table
  • If prompted to save, click Yes/No

To alter your Table design:

  • View the Tables (as before)
  • Right click on your table
  • Select 'Design Table'
  • Make changes
  • Press CTRL-F4 to exit
  • If prompted to save, click Yes/No

To enter data into your Table:

  • View your Tables (as before)
  • Right click on your table
  • Select 'Open Table', 'Return All Rows'
  • Start entering data, row by row
    • Note that this table viewer is a little buggy. For example, if your table specifies that a GUID should be inserted into a field, it will appear as '<Null>' or as a bunch of zeros until you hit the Run button (exclamation mark icon on the toolbar)

To view Table Properties:

  • View the Tables (as before)
  • Single click on your table
  • Press ALT-Enter




Page 4 of 5



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel