Reputation: 1
I get the underlying error when I run the following query. Can you please help?
MY QUERY:
insert into MyDatabaseName.dbo.BoxContents (BoxContentID, Deleted, CreatedBy, CreatedDate, ModifiedBy, ModifiedDate, AuthCode, BoxID, ItemID, VariantAID, VariantBID, VariantCID, SerialNo, LotNo, Amount, Amount2, Amount3, SpecialCode, IntCode, Transferred, TransferDate, Locked, LockedBy, InOut)
select BoxContentID, Deleted, CreatedBy, CreatedDate, ModifiedBy, ModifiedDate, AuthCode, BoxID, ItemID, VariantAID, VariantBID, VariantCID, SerialNo, LotNo, Amount, Amount2, Amount3, SpecialCode, IntCode, Transferred, TransferDate, Locked, LockedBy, InOut
from MyDatabaseName2.dbo.BoxContents
where not BoxContentID in (
select BoxContentID
from MyDatabaseName.dbo.BoxContents
where CreatedDate > dateadd(day, - 19, GETDATE())
)
and CreatedDate > dateadd(day, - 19, GETDATE())
ERROR MESSAGE:
SQL Server detected a logical consistency-based I/O error: torn page It occurred during a read of page (1:15856129) in database ID 9 at offset 0x00001e3e402000 in file 'H:\KLON_DATA**my database name.mdf'. Additional messages in the SQL Server error log or system event log may provide more detail. This is a severe error condition that threatens database integrity and must be corrected immediately. Complete a full database consistency check (DBCC CHECKDB). This error can be caused by many factors; for more information, see SQL Server Books Online.
Upvotes: 0
Views: 7889
Reputation: 28910
There may be some issues with your hard disk or this may be a one time error due to some unexpected issue with your hard disk..
Few steps you can take
1.run ChkDsk to see ,if your hard disk is in good condition
2.Next as suggested,run Dbcc checkDB to see what are the errors
DBCC CHECKDB (yourdbname)
based on the errors and repair option suggested,you can take next steps.Here is a good link to start with
https://learn.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-checkdb-transact-sql
to know more on checkDB,see below link
checkdb from every angle by Paul Randal
Upvotes: 0
Reputation: 41
You should run a DBCC checkdb command against your target database. That error signifies that there may be an issue with page corruption in your database file. Running the command should tell you what is corrupt. You may get lucky and it will just be an index that can be dropped and recreated.
Please see this MSDB article for syntax
Upvotes: 1