Click here to Skip to main content
15,887,027 members
Home / Discussions / Database
   

Database

 
AnswerRe: Firing trigger on a bulk like insert Pin
Mycroft Holmes4-Mar-09 16:30
professionalMycroft Holmes4-Mar-09 16:30 
QuestionStore 10000 characters Pin
.NET- India 3-Mar-09 20:47
.NET- India 3-Mar-09 20:47 
AnswerRe: Store 10000 characters Pin
Vimalsoft(Pty) Ltd3-Mar-09 20:58
professionalVimalsoft(Pty) Ltd3-Mar-09 20:58 
GeneralRe: Store 10000 characters Pin
.NET- India 3-Mar-09 21:06
.NET- India 3-Mar-09 21:06 
GeneralRe: Store 10000 characters Pin
.NET- India 3-Mar-09 21:15
.NET- India 3-Mar-09 21:15 
GeneralRe: Store 10000 characters Pin
Vimalsoft(Pty) Ltd3-Mar-09 21:30
professionalVimalsoft(Pty) Ltd3-Mar-09 21:30 
AnswerRe: Store 10000 characters Pin
Eddy Vluggen3-Mar-09 22:42
professionalEddy Vluggen3-Mar-09 22:42 
QuestionCould not continue scan with NOLOCK due to data movement Pin
Vimalsoft(Pty) Ltd3-Mar-09 20:41
professionalVimalsoft(Pty) Ltd3-Mar-09 20:41 
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
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go




-- Restore a backed up database
-- Given: the filename and path where the backedup database file is located and the name of the database to restore it as
-- The entry will be restored and a row placed into oDirect.dbo.tbl_dbref - which keeps track of the databases
-- The users for the database must also be restored!
ALTER PROCEDURE [dbo].[sp_RestoreDatabase] 

	@dbname char(32), 				-- the database name to restore as
	@filename char(64), @path char(256)		-- the location of the backuped up database file	(on the SQL Server)

AS

set nocount on

declare @sql nvarchar(3000)

execute('sp_ClearDatabaseConnections ' + @dbname)

-- Restore the database
select @sql = 			' RESTORE DATABASE ' + ltrim(rtrim( @dbname )) + ' FROM DISK = ''' + ltrim(rtrim(@path)) + ltrim(rtrim( @filename )) + ''' ' 
select @sql = ltrim(rtrim(@sql)) + 	'    WITH RECOVERY, '
select @sql = ltrim(rtrim(@sql)) + 	'    MOVE ''' + 'TNGoedit_Data' + ''' TO ''' + ltrim(rtrim(@path)) + ltrim(rtrim( @dbname )) + '.mdf' + ''' , '	-- logical file name to physical name
select @sql = ltrim(rtrim(@sql)) + 	'    MOVE ''' + 'TNGoedit_Log' + ''' TO ''' + ltrim(rtrim(@path)) + ltrim(rtrim( @dbname )) + '_log.ldf' + ''' '	-- logical file name to physical name
--select @sql = ltrim(rtrim(@sql)) + 	'    MOVE ''' + ltrim(rtrim(@dbname)) + '_Data' + ''' TO ''' + ltrim(rtrim(@path)) + ltrim(rtrim( @dbname )) + '.mdf' + ''' , '	-- logical file name to physical name
--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
print @sql
execute ( @sql )

-- Was the command successful or was there a problem
if ( (select @@Error) = 0 ) begin
	-- Put an entry into oDirect.dbo.tbl_dbRef
	-- execute ( 'sp_DataSet_Save ''' + @xml + ''' ' ) 	

	-- TODO: restore the users

  select 'Restore Successful' [Result]
end
else begin
   select 'Restore Unsuccessful' [Result]
end


/*	-- Example of a restore
RESTORE FILELISTONLY
   FROM DISK = 'C:\Inetpub\wwwroot\oBooking\Databases\oBookingMasterDB' 

RESTORE DATABASE tst
   FROM DISK = 'C:\Inetpub\wwwroot\oBooking\Databases\oBookingMasterDB' 
   WITH RECOVERY,
   MOVE 'LBS_Data' TO 'C:\Inetpub\wwwroot\oBooking\Databases\tst.mdf',	-- logical file name to physical name
   MOVE 'LBS_Log' TO 'C:\Inetpub\wwwroot\oBooking\Databases\tst_log.ldf'	-- logical file name to physical name
*/



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.

Vuyiswa Maseko,

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."

C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
www.ITS.co.za

QuestionHow to access a table located in different database server. Pin
Spunky Coder3-Mar-09 19:19
Spunky Coder3-Mar-09 19:19 
AnswerRe: How to access a table located in different database server. Pin
Vimalsoft(Pty) Ltd3-Mar-09 20:47
professionalVimalsoft(Pty) Ltd3-Mar-09 20:47 
QuestionSQL server taking 100% of proccesor Pin
AlexeiXX33-Mar-09 18:40
AlexeiXX33-Mar-09 18:40 
QuestionGet only updated and newly record Pin
Abdul Rahman Hamidy3-Mar-09 17:44
Abdul Rahman Hamidy3-Mar-09 17:44 
AnswerRe: Get only updated and newly record Pin
Riaan Booyzen3-Mar-09 20:23
Riaan Booyzen3-Mar-09 20:23 
AnswerRe: Get only updated and newly record Pin
Isaac Gordon27-Mar-09 3:06
Isaac Gordon27-Mar-09 3:06 
QuestionVery basic Prolog question Pin
aab199023-Mar-09 13:34
aab199023-Mar-09 13:34 
QuestionTrouble understanding following sql Pin
pzn3xq3-Mar-09 9:31
pzn3xq3-Mar-09 9:31 
AnswerRe: Trouble understanding following sql Pin
Syed Mehroz Alam3-Mar-09 19:24
Syed Mehroz Alam3-Mar-09 19:24 
QuestionROWDELIMITER for bulk insert [modified] Pin
Brian Kavanagh3-Mar-09 5:57
Brian Kavanagh3-Mar-09 5:57 
AnswerRe: ROWDELIMITER for bulk insert Pin
Ashfield4-Mar-09 1:11
Ashfield4-Mar-09 1:11 
GeneralRe: ROWDELIMITER for bulk insert Pin
Brian Kavanagh4-Mar-09 6:39
Brian Kavanagh4-Mar-09 6:39 
GeneralRe: ROWDELIMITER for bulk insert Pin
Ashfield4-Mar-09 8:42
Ashfield4-Mar-09 8:42 
GeneralRe: ROWDELIMITER for bulk insert Pin
Brian Kavanagh4-Mar-09 10:09
Brian Kavanagh4-Mar-09 10:09 
GeneralRe: ROWDELIMITER for bulk insert Pin
Ashfield4-Mar-09 21:00
Ashfield4-Mar-09 21:00 
GeneralRe: ROWDELIMITER for bulk insert Pin
Brian Kavanagh6-Mar-09 2:57
Brian Kavanagh6-Mar-09 2:57 
GeneralRe: ROWDELIMITER for bulk insert Pin
Ashfield6-Mar-09 4:53
Ashfield6-Mar-09 4:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.