SQL Server Restore Error - Write on ??? failed - sql

I'm trying to restore a full backup (SQL Server 2008) from a network drive and I'm getting the error message:
Msg 3202, Level 16, State 1, Line 1
Write on "???" failed: 1(Incorrect function.)
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
I've tried twice with the most recent full backup, I then went to an older full backup, they all fail with the same message at around 90%
My first guess is that this is an issue with one of the drives it's restoring to, however chkdsk seems happy and I'm not getting any other related errors in the Event Logs or SQL Server.
Anyone have any suggestions of what to look into?
EDIT: command being used:
restore database CustomerData
from disk = '\\server\SQL Archive\CustomerData - 20170225.bak'
with file = 1,
move 'CustomerData_Data' to 'C:\MSSQL\Data\CustomerData_Data.mdf',
move 'CustomerData_Index' to 'D:\Program Files\Microsoft SQL Server\MSSQL10_50.VDI01P\MSSQL\DATA\CustomerData_Index.ndf',
move 'CustomerData_Log' to 'D:\Program Files\Microsoft SQL Server\MSSQL10_50.VDI01P\MSSQL\DATA\CustomerData_Log.ldf',
password = '',
mediapassword = '',
norecovery;

Just a guess, but do you have sufficient space left on the target drive ?
Also, this thread is potentially relevant to your situation: SQL Server backup fails on disk space error

Related

SQLVDI error when backing up to Azure Storage BLOB

I'm running a patched SQL 2014 trying to backup a database to one of our Azure Storage BLOBs, using:
BACKUP DATABASE [DB]
TO URL = N'https://storage.blob.core.windows.net/server-mssqlserver/DB.bak'
WITH CREDENTIAL = N'AzureCredential'
,NOFORMAT
,NOINIT
,NAME = N'DBA_DB-Full Database Backup'
,NOSKIP
,NOREWIND
,NOUNLOAD
,COMPRESSION
,STATS = 5
GO
but the query throws the following error:
Msg 3292, Level 16, State 9, Line 1
A failure occurred while attempting to execute Backup or Restore with a URL device specified. Consult the Windows Event Log for details.
Msg 3013, Level 16, State 1, Line 1
BACKUP DATABASE is terminating abnormally.
Checking the server's Event Logs shows the actual error as:
SQLVDI: Loc=IdentifySQLServer. Desc=MSSQLSERVER. ErrorCode=(5)Access is denied.
. Process=4668. Thread=6596. Client. Instance=MSSQLSERVER. VD=.
I have made sure that the SQL Server Agent service's account has the Create global objects policy, and also made sure the SQL VSS Writer service is running under the Local System account. The error keeps happening!
Is there something I can do to fix it, or just log some more detailed error messages than the "SQLVDI: Loc=IdentifySQLServer" one above?
Crikey, this is one of those "no idea how I fixed it" things.
Before I went to lunch, I could reliably generate the error in question by running the provided T-SQL, yet when I came back from lunch the BACKUP command completed fine!
The main thing I remember changing was on the Azure side, where I created a SAS (Shared Access Signature).
This is supposedly not required for SQL 2014 as it uses an actual Azure Credential to connect to the storage instead. I actually created the SAS for an instance of SQL Server 2016 that I want backing up to the same container, and that may have opened the access pathway to the container for SQL Server 2014 too!
Many thanks to Sean Gallardy for recommending ProcMon, which showed a whole ton more error log information than the "ErrorCode=(5)Access is denied" message did.

MDF File not Opening in SQL Server

My database file of SQL Server 2012 cannot be opened, it causes the following error.
Msg 824, Level 24, State 2, Line 1
SQL Server detected a logical consistency-based I/O error: incorrect pageid (expected 1:903; actual 0:0). It occurred during a read of page (1:903) in database ID 6 at offset 0x0000000070e000 in file 'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\inventoryDB.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.
I also checked it by using
DBCC CHECKDB(inventoryDB, REPAIR_ALLOW_DATA_LOSS)
But the result is given below
DBCC results for 'inventoryDB'.
CHECKDB found 0 allocation errors and 0 consistency errors in database 'inventoryDB'.
Is any possibilities to recover my data from that database file? I am also done many methods in many of the sites. But it not working and shows same error messages.
Do you have any mdf backup after this error occurred? If yes, you should try to create a table and restore from it using your backup.
Or try reading this article:
https://support.microsoft.com/en-ph/kb/2152734
See if it helps with your error.
You've got corruption in your DB. Either the DB was corrupt before you tried working it and you didn't notice, or it was damaged in the work.
Here. We have few options.
Solution one - If you have a backup file, You can restore your database.
Solution two - If you do not have a backup file, you can use DBCC CHECKDB to repair it. (Resource : https://www.stellarinfo.com/blog/how-to-repair-sql-database-using-dbcc-checkdb-command/)
Thanks :)

DB restoration issue

I have a issue while trying to restore a DB. Earlier I had SQL Server 2000 on my system so I installed SQL Server 2005 and now I'm trying to upload a DB backup made on SQL Server 2005 only. While uploading that I'm getting the following:
The query is
restore database APR15THB from disk ='C:\datab\APR15MUR.bak' with replace ,
move 'Apr07Trans_dat' to 'c:\overseas\mil-data\APR15THB.mdf',
move 'Apr07Trans_log' to 'c:\overseas\mil-data\APR15THB.ldf'
The error is
Msg 3169, Level 16, State 1, Line 1
The backed-up database has on-disk structure version 611. The server supports version 539 and cannot restore or upgrade this database.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
Can anyone please help me with this?
No, you can not restore a backup taken with a more modern version to a more outdated sql server.
SImple like that.
ALL your server versions are old, but you running 2000 is ancient. What about doing an update like every 15 years?
Check
https://support.software.dell.com/litespeed-for-sql-server/kb/30314
(yeah, google really has a lot on that stuff). Quite obviously you seem still to restore on 2000. Getting confused with multiple instances installed - i.e. you did not upgrade 2000 to 2005 but installed 2005 side by side and still use the 2000 version for restore?

Error 3241 when restore back up in sql server 2012

when i was restore database in sql server 2012 this error happend
Msg 3241, Level 16, State 0, Line 3
The media family on device 'D:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Backup\Test.bak' is incorrectly formed. SQL Server cannot process this media family.
Msg 3013, Level 16, State 1, Line 3
RESTORE HEADERONLY is terminating abnormally.
what should i do?
What version of SQL Server did you take this backup from? Usually you get this error when you are trying to restore a backup taken on a higher version of SQL Server (Such as 2012) onto a lower version (Such as 2008 R2).
If that is the case, you will need to script out your database and recreate it on the new server rather than simply backing up and restoring.
If the file has not come from a newer version of SQL server than the one you are trying to restore it onto, it is possible that the file has simply been corrupted, at which point you should try to take a new backup if possible. If you are attempting to restore across the network, you should also check permissions to make sure that this is not causing your issue too.

SQL Server 2012 Migrating Spatial data across a Linked server, Query timeout?

We are doing a migration from our old system (sql server 2008) to the new system (SQL server 2012) , the data sources we are using are Remote so we have it configured as a linked servers , the data in the source we are migrating have special data (Geography type) , we are migrating the data per customer , so some customers have more data that the others, we batch the data and we are using OPENQUERY to pull the Spatial data across. For the customers with less data the migration goes smoothly and it completes successfully , but for customers with more than couple million records in one table the migration stops and gives mainly 2 errors:
This how the error comes like :
OLE DB provider "yyy" for linked server "xxx" returned message "Query timeout expired".
Msg 7399, Level 16, State 1, Server nnn, Line 1
The OLE DB provider "yyy" for linked server "xxx" reported an error. Execution terminated by the provider because a resource limit was reached.
Msg 7320, Level 16, State 2, Server ttt , Line 1
Cannot execute the query "
select top (200000)
[row] = row_number () over ( order by t.[x])
, .....
, [Spatial] = cast(ts.[Spatial] as varbinary(max))
from [..].[..].[..] t
join [...].[..].[… ] s
on t.[..] = s.[...]
where (t.[x] > '00000000-0000-0000-0000-000000000000')
and v.[x] = x
order by t.[x]
" against OLE DB provider "yyy" for linked server "xxx".Build step 'Execute Windows batch command' marked build as failure
also this problem happened with one other table that doesn't have a spatial data in it.
The approaches we tried to follow,
We have increased the timeout of the query,
We have dropped the batch size to 200,000 per batch
The Provider is “ in process mode”
we only have couple linked servers so the buffer size is more than acceptable ,
We tried to run the migration using an admin role to make sure it’s not a permissions problem
We are thinking this might be a network problem but it’s not a Load Balancer issue. maybe its something else,
The other error that comes frequently is
HResult 0x40, Level 16, State 1
TCP Provider: The specified network name is no longer available.
Any idea's for what could be a reason will be so much appreciated
Thank you,
Lsaif
I would say the "The specified network name is no longer available." error indicates no response from the remote server. Since SQL Server hasn't "heard" from the remote server in a while, it gives up. I would cut down the batch size to something really small and increase with success (rather than the other way around). That way you'll find a batch size that works. Also, this may vary between "customers" depending on your connection to them (i.e., type and size of line, traffic on the line, etc.).
Personally, I like the BCP OUT/BCP IN option as well because I know it works however, you still have to consider the transfer method of the data from the remote server. If you have a robust enterprise MFT over a dedicated T1 or better, you probably won't have an issue.
SSIS offers more of a direct transfer but I imagine you'll run into the same network issues you're having now. That said, you can create a general BCP solution within SSIS.