Solved

Identity Specification has Changed by it self?

Posted on 2014-02-18
6
265 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 65

Accepted Solution

by:
Jim Horn earned 250 total points
ID: 39867491
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
ID: 39867543
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
ID: 39869322
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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

Author Comment

by:Kim Neesgaard
ID: 39869559
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
ID: 39871977
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
ID: 39872627
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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Removing SCCM 2016 4 53
SQL Convert rows to columns 5 34
Error "Could not load mobile report" in SQL SSRS 2016 after SP1 CU2 Update 2 43
relocating SQL 2000 18 36
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

739 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