SQL Server Identity Issues
Looking for some help, as this SQL thing is new to me. I was required to copy data from one table to another used for a billing application. To do so, I simply copied the entire table using SELECT INTO statement. The application now refuses to insert new records into the table that I had copied. I am using SQL Server 2008, and suggest it has something to do with the Identity column, but not sure. As stated above, this is all new to me. Any help or suggestions where to start would be awesome. Thank-you in advance.
The table that I copies looked like such...
InsuranceID int IDENTITY, Insurance_ID varchar(20), Insurance_Name varchar(100), Address varchar(100),
.. And so on. This is the stored procedure used to insert new records into the table.
Insert Into tblInsuranceCompanies (Insurance_ID, InsuranceName, InsuranceTypeID, Telephone, Extension, Fax, Address, City, State, Zip_Code) Values (@InsuranceID, @Name, @TypeID, @Telephone, @Extension, @Fax, @Address, @City, @State, @Zip) SELECT @@IDENTITY AS InsuranceID
First I thought it is an Identity_Insert problem, which I suggested this: before trying to insert data you can use SET IDENTITY_INSERT products ON
SET IDENTITY_INSERT products ON GO INSERT INTO YOUR_TABLE SELETC * FROM TempTable GO SET IDENTITY_INSERT products OFF GO
but after noticing that the Identity column is not there in the select list, and since all the columns definitions are NOT NULL, i guess one of the values you are trying to insert is null which is causing the error.