August 23, 2010 at 11:13 am
Hello,
I have a situation where the cursor is not completely executing all the results coming from the Select statement.
I have a Select statement from sys.databases to get the name of the databases and for each database do a backup it works fine.
But i have 35 db's it's only doing for 20 databases and exiting without any error.
Are there any limitations.
Any help on this is appreciated.
Thanks,
August 23, 2010 at 11:27 am
show us the script you are using...are you tal\king into consderation non-standard database names?
ie select * from [My Database With Spaces Or a Reserved Word].dbo.sys.objects?
Lowell
August 23, 2010 at 11:36 am
DECLARE complex_cursor CURSOR FORWARD_ONLY FOR
SELECT name from master..sysdatabases where name not in('Tempdb')
order by name
Open complex_cursor;
FETCH next from complex_cursor into @dbname
WHILE @@fetch_status = 0
BEGIN
set @dbname = upper(@dbname)
set @backupname = @dbname + '_ FULL Backup'
set @backupdesc = @dbname + ' FULL Backup Using LiteSpeed '
EXEC @result = master.dbo.xp_backup_database
@database= @dbname
,@tsmobject= @tsmobject1
, @tsmconfigfile= @stsmconfigfile
,@backupname = @backupname ,@desc = @backupdesc
, @init= 1 ,@tsmxmlcachesize= 100000000 , @with = 'stats = 10'
If @result <> 0
RAISERROR ('Backup Failed',16,1)
FETCH next from complex_cursor into @dbname
END
CLOSE complex_cursor;
DEALLOCATE complex_cursor;
August 23, 2010 at 3:48 pm
chinn (8/23/2010)
DECLARE complex_cursor CURSOR FORWARD_ONLY FORSELECT name from master..sysdatabases where name not in('Tempdb')
order by name
Open complex_cursor;
FETCH next from complex_cursor into @dbname
WHILE @@fetch_status = 0
BEGIN
set @dbname = upper(@dbname)
set @backupname = @dbname + '_ FULL Backup'
set @backupdesc = @dbname + ' FULL Backup Using LiteSpeed '
PRINT @dbname
EXEC @result = master.dbo.xp_backup_database
@database= @dbname
,@tsmobject= @tsmobject1
, @tsmconfigfile= @stsmconfigfile
,@backupname = @backupname ,@desc = @backupdesc
, @init= 1 ,@tsmxmlcachesize= 100000000 , @with = 'stats = 10'
If @result <> 0
RAISERROR ('Backup Failed',16,1)
FETCH next from complex_cursor into @dbname
END
CLOSE complex_cursor;
DEALLOCATE complex_cursor;
Add the line I put in bold above, and tell us what you get for output.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
August 26, 2010 at 9:44 am
I did add that code and it prints all the dbnames correctly but it doesnt execute the backup command after it does back for some databases...
It's not erroring out..it just quits...saying it completed successfully.
Is there a way i can rewrite this using if else or while ...
Thanks...
August 26, 2010 at 10:04 pm
Try executing master.dbo.xp_backup_database on QA for one of the databases that is not being backup and see what you get.
August 26, 2010 at 10:49 pm
Also if that returns without errors and doesn't backup the database then you can try running a BACKUP DATABASE command on the same database, if that also fails it will give you a detailed error, if it succeeds then you'll know that the problem is with LiteSpeed so you can seek support from them.
August 27, 2010 at 6:26 am
I did try all of these...they are working..it's quitting as of there is some limitation some where..i am thinking at present on the tape..but i cant prove that because there is no error..
May be i can backup to disk and see what happens....
Thanks For Your Help!!!
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply