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
 Really New

Author  Topic 

Hornetsoft
Starting Member

4 Posts

Posted - 2014-10-03 : 15:37:24
I have just taken over the IT Support of a Food company and they have some data loggers that store data in SQL 2005 Express and the dbase is at 4gb. I want to see the data using Managment Studio and delete some of the very old records in the database but I havent got a clue where to find them. I am used to mysql and phpmyadmin and can do it no problem using that but am a bit mystified trying todo it using Management Studio any help much appreciated.

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-10-03 : 15:55:57
can you open the database in SSMS and see the list of tables? Then, look for the tables you are interested in. For one of those, right-click on the table and select Select Top nnn rows. Now you can see the data. You can also edit it from the same context menu, though for clean up I suspect you'll need to write some T-SQL. Don't forget to backup before you clean up!
Go to Top of Page

Hornetsoft
Starting Member

4 Posts

Posted - 2014-10-03 : 16:26:45
That's a great start I have found the problem table and right clicked and opened and found one almighty table the records are still counting up to 500k already. I am not sure what T-SQL is sorry I am a total SQL novice never used it before at all ? So can I not just highlight a few thousand old ones and just delete them sorry if this is a daft question.
Go to Top of Page

Hornetsoft
Starting Member

4 Posts

Posted - 2014-10-03 : 16:29:25
Its a data logger for cookers and fridge temperatures and it looks like its not been cleared out since 2010 as they only need to keep records going back a year I wish to remove the records say older than two years then shrink the database so its a more sensible size.
Go to Top of Page

Hornetsoft
Starting Member

4 Posts

Posted - 2014-10-03 : 16:40:03
I have had a quick look at T-SQL and I think this is the command below how do I run this command please
DELETE FROM dbo.Readings
WHERE DateTime < 01/01/2012 00:00:00;
GO
Go to Top of Page

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-10-04 : 08:52:01
That should do it. Take a backup first!
Go to Top of Page
   

- Advertisement -