0
I have a serious problem in my database. Some of my tables were created with Pk and Identity (1, 1) which is standard. However, when restoring the database some of these tables get PK NULL and when inserting data into the table, it starts with pk 0; this generates mts failures....... Someone can help me (I’m amazed?)
CREATE TABLE MyTable(
MyTableID int IDENTITY(1,1) NOT NULL,
RecordName nvarchar(100) NULL)
INSERT MyTable(RecordName)
VALUES('Valor Qualquer')
SELECT * FROM MyTable
-- 0 , Valor Qualquer
Select last_value
From sys.identity_columns
Where object_id = 'MyTable'
-- NULL
How to change "NULL" to 0 ?
Put your table’s creation code in the question and also the
INSERT
– Sorack
Edit your question and add the data to it
– Sorack
Add this information to the question. Click edit and add there. Comments are not for more information.
– Sorack
admitting that "restoration of the bank" means "install a backup", found some references confirming that when this happens some constraints (among other controls) are lost. Take a look at at that link which explains what happens and how to solve, should help ;)
– rLinhares