Next / Previous / Index / ITC Help System / Publications / Site map / NM Tech homepage

Inserting data in specific Sybase columns

Tech Computer Center logo

At the end of each command press the space-bar or press enter before continuing the next step.

  1. To add data in specific columns of your table, type
            insert into
  2. Type the name of the table you are entering data into.
  3. Now you have to tell the server what columns you are entering data for. These columns need to be grouped by parenthesis, and if there is more than one, separated by commas.
  4. To start the grouping, type
  5. Type the first column name, followed by a comma, then any other column names, each separated by a comma.
  6. Type
    to close the group.
  7. Type
  8. Since you are entering data for at least one column, the data needs to be grouped and each value needs to be separate. To group the values, you enclose them in parenthesis. To separate them, you use commas.
    If you have special characters to enter as values into your tables (that includes % _ , ( ) < > . : = + - * / ' " and the space character) you must quote the value. To do that, enclose the value between single close quotes. For instance, to use fifteen percent, you would type '15%' To get a ' character, you type it twice. For example 'it''s' would enter the contraction for ``it is'' as a value.
  9. To begin the group, type
  10. Type the data for the first column, followed by a comma, then the data for the second column, followed by a comma, until you have values for all the columns. Make sure you enter the data in the same order as you named the columns above.
  11. Close the group by typing
  12. Type
  13. Press Enter.

    If everything goes well, you see

            (1 row affected)
    then the database prompt (a period, the name of the database you are using, another period, the number one and then the greater than symbol).

    If you see

            Msg 102, Level 15, State 1
            Server '', Line 1
            Incorrect syntax near '89'.
    you could have done a lot of things wrong. You could have entered data that is not the correct type for a column (text in an integer field for example). You could have used more values than you have columns. You could have used fewer values than columns. You could have forgotten the commas. Take a close look at your insert statement and compare it to your table structure. When you figure out what went wrong, try it again. This type of error, which I think is the most likely error to be made, has the least helpful error code in the entire program.

    If you type the data in the wrong order (for instance, putting a name in a city column) Sybase will not give you an error, but you will be surprised when you look at the data later because everything will be wrong. Be very careful. This is a very common human error that can be very difficult to avoid. When you have entered data, double-check it by searching the database for your entries. If you can't find the entry you are searching for, or there is incorrect data, you can correct it. If you don't do this, your searches will return incorrect data.

    Next: Modifying data in a Sybase column
    See also: Adding and modifying data in Sybase
    Previous: Example of adding data in Sybase
    Site map
    Index: Keyword index to help pages
    Help: New Mexico Tech Information Technology and Communications: Help System
    ITC Publications
    To report a problem: File a ticket
    Send mail to the User consultant on duty or call them at 575-835-5437
    Home: About New Mexico Tech

    Maintained by John Shipman,; original by Steve Anderson
    Last updated: 1997/06/23 23:05:38 UT
    QR two-dimensional bar code