Solved

Identity Specification has Changed by it self?

Posted on 2014-02-18
6
257 Views
Last Modified: 2014-02-19
Hi all!

I have some SQL Server tables on a server and one of the tables uses identity specification as unique ID. When I insert a new record in the table, I use INSERT INTO table (fields) VALUES (some values) and then the system inserts the next ID in the table. It has worked very well for a long time.

'Suddenly' one of the uses get an error that says: column does not allow nulls. INSERT fails. After investigation of the table in question, I discover that identity specification is set to 'no'. I am very sure that I have not changed the value to 'no' and no other has access to the table.

My question is: is it possible that this value can change 'by itself' or could there be circumstaces where the value is changed so ti appear that it has chenged 'by itself'?

After I changed to 'yes', no problems exist.


Best regards
Kim Neesgaard
0
Comment
Question by:Kim Neesgaard
  • 3
  • 2
6 Comments
 
LVL 65

Accepted Solution

by:
Jim Horn earned 250 total points
Comment Utility
The only logical explanations..
This table was imported from a source to its current location in a manner where the Identity was not in the newly-created table.
Somebody executed a script that did this.
Somebody manually did this, likely to force an insert with a specific value, and forgot to set it back.
Gremlins
0
 

Author Comment

by:Kim Neesgaard
Comment Utility
Hi Jim!

Thank you for your answer! Actually I can see (and recall) that there has been some copy activities for exactly this table so your first guess seems likely. I certainly not hope for you last suggestion...!


Best regards
Kim Neesgaard
0
 
LVL 75

Assisted Solution

by:Anthony Perkins
Anthony Perkins earned 250 total points
Comment Utility
The only way that can happen is if you allow someone to rebuild the table.  There is no other way.  You cannot change the IDENTITY attribute without re-creating the table.

So if you want to prevent this from happening in future, tighten your security and do not allow users to use sa (hint hint) and this problem will go away.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:Kim Neesgaard
Comment Utility
Hi Anthony!

I was allowed to change identity specification from no to yes but perhaps a rebuild was made behind the scenes. In the options 'prevent saving changes that require table re-creation' is not ticked.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
Comment Utility
I was allowed to change identity specification from no to yes but perhaps a rebuild was made behind the scenes.
You are right, behind the scene SSMS is rebuilding the table.  You can see exactly what I mean by "removing" the attribute in the Table Designer but instead of clicking Save, select the icon that reads "Generate Change Script" (it is also under the Table Designer menu.
0
 

Author Comment

by:Kim Neesgaard
Comment Utility
I have just checked it and it is very visible under Generate Change Script - I didn't know this function. Thank you for elaborate the question!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The purpose of this article is to demonstrate how we can use conditional statements using Python.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now