Home

Visual Data Entry

 

Introduction

As you are probably aware already, columns are used to organize data by categories. Each column has a series of fields under the column header. One of the actual purposes of a table is to display data that is available for each field under a particular column. Data entry consists of providing the necessary values of the fields of a table. Data is entered into a field and every time this is done, the database creates a row of data. This row is called a record. This means that entering data also self-creates rows. Except for any unknown reason I can't think of, when using the Data In Table window from the Enterprise Manager, you will never have to create rows of a table. They are created automatically as the user is entering data.

There are four main ways you can perform data entry for a Microsoft SQL Server table:

  • You can use a table from the Enterprise Manager
  • You can enter data by typing code in the SQL Query Analyzer
  • You can import data from another object or another database
  • You can use an external application such as Microsoft Access, Microsoft Visual Basic, Borland C++ Builder, Microsoft Visual C++, Borland Delphi, Microsoft Visual Basic .NET, C#, Visual C#, J#, etc.

Using the Enterprise Manager

Probably the easiest and fastest way to enter data into a table is by using the Enterprise Manager. Of course, you must first open the desired table from an available database. In the Enterprise Manager, after selecting the database and the Tables node, to open a table for data entry, right-click it, position your mouse on Open Table, and click Return All Rows. If the table does not contain data, it would appear with one empty row. If some records were entered already, their rows would show and the table would provide an empty row at the end, expecting a new record:

To perform data entry on a table, a user would click in a field. Each column has a title, called a caption, on top. This gray section on top is called a column header. In SQL Server, it displays the actual name of the column. When using external and friendlier applications, you will find out that the caption can be different from the actual name of a column.

The user refers to the column header to know what kind of data should/must go in a field under a particular column. This is why you should design your columns meticulously. After identifying a column, a user can type a value. Except for text-based columns, a field can accept or reject a value if the value does not conform to the data type that was set for the column. This means that in some circumstances, you may have to provide some or more explicit information to the user.

While performing data entry, the user may skip some fields if the information is not available. The user can skip only columns that allow NULL values. If a column was configured as NOT accepting NULL values, the user must enter something in the field, otherwise he would receive an error and the table would not allow going further.

Practical LearningPractical Learning: Performing Data Entry on a Table

  1. In the left frame, right-click the Databases node and click New Database...
  2. Set the database Name to WorldStats1
  3. Click the Data Files property page and set the Initial Size to 5
  4. Click OK
  5. Expand the WorldStats1 database and click the Tables node. Right-click the Tables node and click New Table...
  6. Create the table with the following columns (any empty box in the following table means use the default or don't change):
     
    Column Name Data Type Length Allow Nulls
    CountryName varchar 80 Unchecked
    Area int    
    Population bigint    
    Capital varchar   Unchecked
    Code char 2  
  7. Close the table
  8. When asked whether you want to save it, click Yes
  9. Type Countries as the name of the table and click OK
  10. In the right frame, right-click Countries, position the mouse on Open Table and click Return All rows
  11. As the cursor is positioned in the first empty field under CountryName, type Cote d'Ivoire and press Enter
  12. Type 322460 and press Tab
  13. Type 16,393,221 and press Enter
  14. Notice that you receive an error because the commas are not allowed:
     
  15. Click OK on the error message box.
  16. Change the value to 16393221 People and press Tab
  17. Notice that you receive another error because the column is configured for a natural number and not a string
  18. Click OK on the error message box and delete People
  19. Click under InternetCode, type td and press Enter
     
  20. Notice that you receive an error because you left the Capital field empty in the previous record although the Capital column does NOT allow NULL
  21. Click OK on the error message box
  22. Click the field under Capital, type Yamoussoukro and press Enter twice
  23. Notice that we typed td as the Internet Code for Cote D'Ivoire and the database allowed it. The Internet Code of Cote d'Ivoire is not td. This was done to illustrate that the database engine does not perform such validations unless explicitly directed to do so
  24. Under InternetCode, double-click td to select the entry, type ci and press Enter
  25. Complete the table as follows:
     
  26. Close the table
 

Previous Copyright © 2005-2016, FunctionX Next