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

Answers


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

like this:

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.


Need Your Help

Return only most recent call per caller

python django

Let's say you have a model that represents a call log containing: the person you called (calledid), the date of the call (calldate), and wether or not the person called needs to be recontacted or n...

Select distinct column along with some other columns in MySQL

mysql select distinct

I can't seem to find a suitable solution for the following (probably an age old) problem so hoping someone can shed some light. I need to return 1 distinct column along with other non distinct colu...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.