Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Problem inserting values.

Problem inserting values.

Scheduled Pinned Locked Moved Database
helpdatabasesql-serversysadmin
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    Omar Akhtar Sheikh
    wrote on last edited by
    #1

    I have set the EMP_ID column in my database as the Primary Key. I mean this is the primary key column. And when I try to insert values in my database table from the form in then it gives me an error as:          "Cannot insert explicit value for identity column in table 'Employees' when IDENTITY_INSERT is set to OFF." So, how is the IDENTITY_INSERT set to on. Where it is actually located so that I can modify it and start to insert values into my table. Moreover, when I remove the primary key from this column(EMP_ID) and uncheck the Allow Nulls checkbox then also my same problem persists. Kindly help me out. I am currently using SQL Server 2005.

    E O R 3 Replies Last reply
    0
    • O Omar Akhtar Sheikh

      I have set the EMP_ID column in my database as the Primary Key. I mean this is the primary key column. And when I try to insert values in my database table from the form in then it gives me an error as:          "Cannot insert explicit value for identity column in table 'Employees' when IDENTITY_INSERT is set to OFF." So, how is the IDENTITY_INSERT set to on. Where it is actually located so that I can modify it and start to insert values into my table. Moreover, when I remove the primary key from this column(EMP_ID) and uncheck the Allow Nulls checkbox then also my same problem persists. Kindly help me out. I am currently using SQL Server 2005.

      E Offline
      E Offline
      Ebube
      wrote on last edited by
      #2

      it depends on what you want to do. if you want to enable insertion on identity column SET IDENTITY_INSERT [ database_name . [ schema_name ] . ] table { ON | OFF } otherwise remove identity from the emp_id column and insert the value from field

      E 1 Reply Last reply
      0
      • E Ebube

        it depends on what you want to do. if you want to enable insertion on identity column SET IDENTITY_INSERT [ database_name . [ schema_name ] . ] table { ON | OFF } otherwise remove identity from the emp_id column and insert the value from field

        E Offline
        E Offline
        Ebube
        wrote on last edited by
        #3

        sorry typo error i mean form not field

        1 Reply Last reply
        0
        • O Omar Akhtar Sheikh

          I have set the EMP_ID column in my database as the Primary Key. I mean this is the primary key column. And when I try to insert values in my database table from the form in then it gives me an error as:          "Cannot insert explicit value for identity column in table 'Employees' when IDENTITY_INSERT is set to OFF." So, how is the IDENTITY_INSERT set to on. Where it is actually located so that I can modify it and start to insert values into my table. Moreover, when I remove the primary key from this column(EMP_ID) and uncheck the Allow Nulls checkbox then also my same problem persists. Kindly help me out. I am currently using SQL Server 2005.

          O Offline
          O Offline
          okdeshpande
          wrote on last edited by
          #4

          I think you are trying to insert a value into a identity column. If you are inserting the value into intentionally then you have to set Identity_insert tablename on/off. else ignore this column while inserting, sql server automatically inserts records into this field.

          1 Reply Last reply
          0
          • O Omar Akhtar Sheikh

            I have set the EMP_ID column in my database as the Primary Key. I mean this is the primary key column. And when I try to insert values in my database table from the form in then it gives me an error as:          "Cannot insert explicit value for identity column in table 'Employees' when IDENTITY_INSERT is set to OFF." So, how is the IDENTITY_INSERT set to on. Where it is actually located so that I can modify it and start to insert values into my table. Moreover, when I remove the primary key from this column(EMP_ID) and uncheck the Allow Nulls checkbox then also my same problem persists. Kindly help me out. I am currently using SQL Server 2005.

            R Offline
            R Offline
            Robin_Roy
            wrote on last edited by
            #5

            If you have access to the Management Studio of SQL Server, try and check the property for the column of your table in design mode, check the Identity Specification property...

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups