Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Identity Specification has Changed by it self?

Posted on 2014-02-18
6
Medium Priority
?
271 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 66

Accepted Solution

by:
Jim Horn earned 750 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 750 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
Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

 

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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

721 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