Could not continue scan with NOLOCK due to data movement

Please support our MS SQL advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Mar 2007
Posts: 157
Reputation: vuyiswamb is an unknown quantity at this point 
Solved Threads: 5
vuyiswamb's Avatar
vuyiswamb vuyiswamb is offline Offline
Junior Poster

Could not continue scan with NOLOCK due to data movement

 
0
  #1
Mar 4th, 2009
Good Morning Friends,

I have a SP that is Supposed to Restore a Database from a Backup. In some Clients this works well but in those particular client its a Problem. The version is SQL 2005.

Here is the Code that fails
  1. SET ANSI_NULLS ON
  2. SET QUOTED_IDENTIFIER ON
  3. go
  4.  
  5.  
  6.  
  7.  
  8. -- Restore a backed up database
  9. -- Given: the filename and path where the backedup database file is located and the name of the database to restore it as
  10. -- The entry will be restored and a row placed into oDirect.dbo.tbl_dbref - which keeps track of the databases
  11. -- The users for the database must also be restored!
  12. ALTER PROCEDURE [dbo].[sp_RestoreDatabase]
  13.  
  14. @dbname char(32), -- the database name to restore as
  15. @filename char(64), @path char(256) -- the location of the backuped up database file (on the SQL Server)
  16.  
  17. AS
  18.  
  19. SET nocount ON
  20.  
  21. declare @sql nvarchar(3000)
  22.  
  23. execute('sp_ClearDatabaseConnections ' + @dbname)
  24.  
  25. -- Restore the database
  26. SELECT @sql = ' RESTORE DATABASE ' + ltrim(rtrim( @dbname )) + ' FROM DISK = ''' + ltrim(rtrim(@path)) + ltrim(rtrim( @filename )) + ''' '
  27. SELECT @sql = ltrim(rtrim(@sql)) + ' WITH RECOVERY, '
  28. SELECT @sql = ltrim(rtrim(@sql)) + ' MOVE ''' + 'TNGoedit_Data' + ''' TO ''' + ltrim(rtrim(@path)) + ltrim(rtrim( @dbname )) + '.mdf' + ''' , ' -- logical file name to physical name
  29. SELECT @sql = ltrim(rtrim(@sql)) + ' MOVE ''' + 'TNGoedit_Log' + ''' TO ''' + ltrim(rtrim(@path)) + ltrim(rtrim( @dbname )) + '_log.ldf' + ''' ' -- logical file name to physical name
  30. --select @sql = ltrim(rtrim(@sql)) + ' MOVE ''' + ltrim(rtrim(@dbname)) + '_Data' + ''' TO ''' + ltrim(rtrim(@path)) + ltrim(rtrim( @dbname )) + '.mdf' + ''' , ' -- logical file name to physical name
  31. --select @sql = ltrim(rtrim(@sql)) + ' MOVE ''' + ltrim(rtrim(@dbname)) + '_Log' + ''' TO ''' + ltrim(rtrim(@path)) + ltrim(rtrim( @dbname )) + '_log.ldf' + ''' ' -- logical file name to physical name
  32. print @sql
  33. execute ( @sql )
  34.  
  35. -- Was the command successful or was there a problem
  36. IF ( (SELECT @@Error) = 0 ) begin
  37. -- Put an entry into oDirect.dbo.tbl_dbRef
  38. -- execute ( 'sp_DataSet_Save ''' + @xml + ''' ' )
  39.  
  40. -- TODO: restore the users
  41.  
  42. SELECT 'Restore Successful' [Result]
  43. end
  44. else begin
  45. SELECT 'Restore Unsuccessful' [Result]
  46. end
  47.  
  48.  
  49. /* -- Example of a restore
  50. RESTORE FILELISTONLY
  51.   FROM DISK = 'C:\Inetpub\wwwroot\oBooking\Databases\oBookingMasterDB'
  52.  
  53. RESTORE DATABASE tst
  54.   FROM DISK = 'C:\Inetpub\wwwroot\oBooking\Databases\oBookingMasterDB'
  55.   WITH RECOVERY,
  56.   MOVE 'LBS_Data' TO 'C:\Inetpub\wwwroot\oBooking\Databases\tst.mdf', -- logical file name to physical name
  57.   MOVE 'LBS_Log' TO 'C:\Inetpub\wwwroot\oBooking\Databases\tst_log.ldf' -- logical file name to physical name
  58. */


And i get the Error

Exception caught in: ExecuteStoredProc: Could not continue scan with NOLOCK due to data movement. RESTORE could not start database 'Testv3'. RESTORE DATABASE is terminating abnormally. Database 'Testv3' cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server errorlog for details.
Thank you.
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 149
Reputation: Geek-Master is an unknown quantity at this point 
Solved Threads: 6
Geek-Master's Avatar
Geek-Master Geek-Master is offline Offline
Junior Poster

Re: Could not continue scan with NOLOCK due to data movement

 
0
  #2
Mar 8th, 2009
Looking at the error message about NOLOCK, I came across this article from Microsoft http://support.microsoft.com/kb/815008. But, this is for SQL Server 2000, which you said you are using 2005. Although, in the same article Microsoft said you can run this TRACE "DBCC TRACEON (9134, -1)" to ignore the row that has a lock on it. Not sure if this will help.
If in doubt, reach into the trash can and remove the user guide.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 157
Reputation: vuyiswamb is an unknown quantity at this point 
Solved Threads: 5
vuyiswamb's Avatar
vuyiswamb vuyiswamb is offline Offline
Junior Poster

Re: Could not continue scan with NOLOCK due to data movement

 
0
  #3
Mar 12th, 2009
Thank you very much for your help.

The Problem is that the Database that i wanted to restore from was Corrupt.

Thank you
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the MS SQL Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC