Reputation: 13367
I am importing data into a blank database and for some reason it is not creating identity columns.
I have selected "Enable identity insert"
But it is not creating the identity column. This is the original one:
id is an identity column, but in the imported table:
Which hasn't created an identity column. Does anyone know why?
Upvotes: 0
Views: 2916
Reputation: 390
may it help
create table YourTableName
(
ID int identity(1,1),
contact_ID int,
ipaddress varchar (50),
task varchar (50)
)
And if you want to insert value in identity column you need to write something like this EXAMPLE :
SET IDENTITY_INSERT YourTableName ON
INSERT into YourTableName(TheIdentity, TheValue)
VALUES (1, 'First Row')
SET IDENTITY_INSERT YourTableName OFF
as you say you have 300+ tables
Go to your column property :
In identity Specification section change IsIdentity No to Yes (By default identity Specification will be NO change to Yes) Identity Increment 1
Upvotes: 0
Reputation: 13367
I figured this out. It right clicked the original database and clicked "Tasks > Generate Scripts" to a new query window. Then I used the Object Explorer (F7) on the target database and deleted all the tables. I made sure the scripts I created in the last step were targeting the new database and then I ran them.
Once this was done, I was able to use the import wizard and check the "Enable identity insert".
This worked.
Upvotes: 1
Reputation: 411
simple. Right click the table, and go to design in SSMS, highlight the primary key.
Check that Identity Specification has the following values.
Upvotes: 1