Re: WARNING. A simple cut and paste of 8 records can distroy a SQL Server table

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Erland Sommarskog (esquel_at_sommarskog.se)
Date: 06/19/04


Date: Sat, 19 Jun 2004 22:34:40 +0000 (UTC)

pete (pete@madpete.freeserve.co.uk) writes:
> Today I need to copy 8 records in a table. I have to use Access 200
> because of the limitation of Enterprise Manager's inability to cope with
> field with more than 900 characters. Selected records, cut, paste. I
> got an erroor message about not being able to have a null Key_ID (I
> copied the reords and tried to paste the Key_ID as part of the records -
> normally I hide the Key_ID).
>
> Now I can't access either the new records or the originals that I was
> trying to copy (because, it would seem, they have identical primary
> keys). I also cannot export the table via DTS 'unspecified error' and
> 'integrity violation'.
> Or delete the offending records with a Query Anaylyser delete query.
> Basically the entire SQL Server database has been destroyed with a
> couple of keystrokes.
> Now, I've being developing database applications for over 20years and the
> one thing, maybe the only thing I expect from a database server is to
> protect the integrity of my data. SQL Server does not, it would seem.

SQL Server protects the integrity of your data, as far as you tell it
what to protect. It cannot make random guesses.

In any case, it is impossible to tell what happened, since you also
involved Access. "Cut and paste" is not a concept that exists in
SQL Server proper. If Access implemented the cut-and-paste with a
DELETE and INSERT, and the INSERT failed, and did not use a transaction,
then SQL Server have to plead innocent.

> These records aren't just any random unimportant records either. They
> contain the 'create views' that my entire application require to
> function and each one approaches the 8000 record limit and have take
> years to perfect and just checking that the table is valid could take me
> days.

It seems a little funny to me that you store source code in a database
table. I would use a version-control system.

But assuming that you had created the views, you can use sp_helptext
to get SQL Server's version of the views. There are also scripting
facilities in Enterprise Manager.

-- 
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp


Relevant Pages

  • Re: Maybe the Records Are There After All
    ... Run DBCC UPDATEUSAGE to correct the row count display in Enterprise Mangler. ... Senior Database Administrator ... I support the Professional Association for SQL Server ... > Enterprise Manager and it gave me the sensation that ALL of the data had ...
    (microsoft.public.sqlserver.server)
  • Re: New to Windows CE Development - Have some questions
    ... validating against the main database, or querying the database during data ... iterate through the SQL CE table and create new entries in the ... SQL Server database that correspond. ... >>> not connected to the Enterprise. ...
    (microsoft.public.windowsce.app.development)
  • Re: MDF file level security from copying
    ... is a way to protect the MDF files, ... located on FAT like Windows 98 and Windows ME, ... >BTW, if you are concerned about the database schema, as ... >> file while the sql server is stopped? ...
    (microsoft.public.sqlserver.security)
  • Re: MS Access DAO -> ADO.NET Migration
    ... William Vaughn ... Microsoft MVP ... Hitchhiker's Guide to Visual Studio and SQL Server ... My migration app works building a SSCE database file with imported data ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: How can I secure a MSDE database for users who have SQL Server?
    ... > How can I protect a MSDE-database so that SQL Server Enterprise ... > Manager always asks for a password if you want to access the database ... if you know the login name and password. ...
    (microsoft.public.sqlserver.msde)