I am using a shared MS SQL server on Godaddy.  I noticed this morning that my each record was duplicated 5 times

goodk
goodk used Ask the Experts™
on
Is it possible at all that godaddy server did this?  I cannot think of any queries I have run to make this possible.

Please please help!!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
ste5anSenior Developer

Commented:
If this is the case, then it's an issue for the GoDaddy support.

Just run a DBCC CHECDB to test the database integrity.

Author

Commented:
Msg 7983, Level 14, State 36, Line 2
User 'kenkenken' does not have permission to run DBCC checkdb for database 'kenkenken'.

Author

Commented:
Use [kenkenken] DBCC CheckDB
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

ste5anSenior Developer

Commented:
Then contact the support.. it maybe database or index corruption.

Author

Commented:
id               description                                      date                                      timestamp
13707      Borrowed from BO Starcity      2014-08-27 00:00:00.000      2014-11-24 12:07:58.237
14646      Borrowed from BO Starcity      2014-08-27 00:00:00.000      2014-11-24 12:07:58.237
15546      Borrowed from BO Starcity      2014-08-27 00:00:00.000      2014-11-24 12:07:58.237
15809      Borrowed from BO Starcity      2014-08-27 00:00:00.000      2014-11-24 12:07:58.237
Scott PletcherSenior DBA
Most Valuable Expert 2018
Top Expert 2014

Commented:
I suspect you had a JOIN on the INSERT that caused additional rows to be generated.  But on the extremely limited info so far, there's no way to really know what happened.
Vitor MontalvãoIT Engineer
Distinguished Expert 2017

Commented:
id               description                                      date                                      timestamp
 13707      Borrowed from BO Starcity      2014-08-27 00:00:00.000      2014-11-24 12:07:58.237
 14646      Borrowed from BO Starcity      2014-08-27 00:00:00.000      2014-11-24 12:07:58.237
 15546      Borrowed from BO Starcity      2014-08-27 00:00:00.000      2014-11-24 12:07:58.237
 15809      Borrowed from BO Starcity      2014-08-27 00:00:00.000      2014-11-24 12:07:58.237
How did you inserted these rows?
Those are all columns in the table?

Author

Commented:
Yes they are columns in the table.  There is a possibility in my code that it is adding extra records.  Not sure what is going on? I am planning to review the code.

Author

Commented:
How can I delete all other identical records except with the lowest ID

Can you suggest a SQL query?
IT Engineer
Distinguished Expert 2017
Commented:
As possible way to delete duplicates.
WITH CTE_LowId AS
    (SELECT MIN(id) MinID, description, date, timestamp
    FROM TableName
    GROUP BY description, date, timestamp)
DELETE FROM TableName T1
INNER JOIN CTE_LowId T2
        WHERE T2.description = T1.description
             AND T2.date = T1.date
             AND T2.timestamp = T1.timestamp
WHERE T1.id > T2.MinId

Open in new window

NOTE: Run this first in a development environment and ONLY when you're sure that it works, then you can run it in Production. As always, perform a backup of the database before run this command.

Author

Commented:
thank you

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial