Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 Data goes missing when manually added

Author  Topic 

hcanning
Starting Member

1 Post

Posted - 2010-08-10 : 16:34:31
Hi Guys,
Complete Newbie. I need to manually add 2-3 rows of data to a table using Ms Sql Server 2005 to allow a user to login with their login details due to a constraint/bug in their usual software that does it. In short I am adding login details to the table.
When I add the data manually in the row of the table using Sql Server 2005 I have some issues:
1 - After adding in the data manually and executing it the row of data I just entered sorts itself within a row amongst 1000's of rows of data way up the page. Should the last row of data not reside at the bottom of the table or is there a way of sorting it?
2 - After a few days the data I manually entered just goes missing and is no longer visible so I have to reinput it again? Any ideas what would cause this? Rows overwriting each other maybe or some automated maintenance script?
3 - Does it matter if cells in rows are just left blank as opposed to NULL - Am i better just copying an existing 'working' row into the 'new' row and just editing the data? Does the copying and pasting bring with it other hidden data.

THANKS!

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2010-08-11 : 04:42:59
First I have to say that manually hacking data in to a database provided by a 3rd party usually is a *very* bad idea unless you know exactly what you're doing. That being said:

1) The fact that it sorts itself is perfectly normal, the data is sorted after the clustered index definition

2) Are you sure that it's completely missing, or can't you find it back?

3) This depends on the application. You should use an existing row as a template for what you're inserting but copying the entire row could cause some undesired results.

All-in-all this sounds like a very bad idea. You should have the people that designed the software fix the problem instead...


- Lumbago

My blog (yes, I have a blog now! just not that much content yet)
-> www.thefirstsql.com
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2010-08-17 : 03:45:12
the case of the missing data if querying them after insertion doesn't reveal them:

1. was the database restored? check sys.databases (create_date) or sysdatabases (crdate) column to give you a hint if a restore was made

2. were the entries deleted? for this you need to create a trigger (create a DML trigger on the table and log the changes to a table located in another database)

3. if it's a job...query...
select j.name,js.step_name,js.
from msdb.dbo.sysjobs j
join msdb.dbo.sysjobsteps js on j.job_id=js.job_id
where js.command like '%drop table%'

4. is the table a subscription table, replication update could have overwritten the changes you made

5. is the table data coming from a data feed somewhere? probably controlled by the application jobs (outside of sql server)?

quite an investigation but my advise is to set up a trigger and see if that one does the trick. Create a server wide DDL trigger as well so it doesn't get affected if something is manipulated to change the database itself e.g. table gets dropped and recreated or something similar.

HTH


--------------------
keeping it simple...
Go to Top of Page
   

- Advertisement -