Inserting values using INSERT INTO

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kisho
    New Member
    • Dec 2011
    • 4

    Inserting values using INSERT INTO

    i have created on table Customer which have [ino] column as primary key and IDENTITY(100000 00,1). What i want is
    how can i insert values for the table using INSERT INTO
    Customers values(<values> ) query
    Be cause it generates
    "An explicit value for the identity column in table 'Customer' can only be specified when a column list is used and IDENTITY_INSERT is ON'
    error"
    i want query method only
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    You need to specify what columns you want to insert into. If you don't specify the columns, it requires that you give values for all columns.
    Code:
    insert into tablename (fieldname) values (1);

    Comment

    • ck9663
      Recognized Expert Specialist
      • Jun 2007
      • 2878

      #3
      You cannot just insert value to an IDENTITY column directly. Here, read this.

      Happy Coding!!!


      ~~ CK

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        I've never had a problem inserting into identity fields. You just have to explicitly specify the field in the field list.

        Comment

        • kisho
          New Member
          • Dec 2011
          • 4

          #5
          Thanks Rabbit...it helped me

          Comment

          Working...