How can we help you today? How can we help you today?
RickyR
For future reference, here is the script that Matt is referring to /* Creation Data : 05/11/2008 This script will look in a directory for SQL Backup .sqb files and restore the newest backup over current databases. The script will also look in a directory for any SQL Backup .sqb files not associated with a current database. The database name will then be extracted from the header, checked against the current system databases. If this is a new database the script will read the file list and restore to a new database, moving 1 data and 1 log file. For more data/log files adjustments will need to be made. This script is provided "AS IS". */ USE master DECLARE @dbname NVARCHAR(260) DECLARE cDatabases CURSOR FOR SELECT name FROM sysdatabases WHERE name != 'tempdb' AND name != 'master' AND name != 'msdb' --Databases to ignore DECLARE @restorepath VARCHAR(500) DECLARE @filename VARCHAR(500) DECLARE @restorestring VARCHAR(1000) DECLARE @exitcode INT DECLARE @sqlerrorcode INT DECLARE @searchstring VARCHAR(500) DECLARE @flagg INT DECLARE @ldata VARCHAR(200) DECLARE @llog VARCHAR(200) SET @restorepath = 'C:Backup' --Directory backups are stored -- Tempory tables to store list of all .sqb files in the @resorepath directory CREATE TABLE #sqbdir ( subdirectory VARCHAR(500), Files BIT, size INT, datemodified datetime ) CREATE TABLE #Files ( subdirectory VARCHAR(500) ) -- Get All files/Folder names in @restorepath INSERT INTO #sqbdir EXEC MASTER..SQBDIR @restorepath -- Filter only backup files with .sqb extension INSERT INTO #Files SELECT subdirectory FROM #sqbdir WHERE subdirectory LIKE '%.sqb' -- Get first database in sysdatabase OPEN cDatabases FETCH NEXT FROM cDatabases INTO @dbname -- While there are more databases @FETCH_STATUS = 0 BEGIN SET @filename = NULL -- Search for .sqb files in the format of FULL_SQL2005_databasename_2date.sqb SET @searchstring = 'Full_SQL2005_' + @dbname + '_2%' -- Get the most recent backup file for the current database, only files in above format will be retrieved. Datastamp in filename used to retreive newest SELECT @filename = subdirectory FROM #Files WHERE subdirectory = ( SELECT TOP ( 1 ) subdirectory FROM #Files WHERE subdirectory LIKE @searchstring ORDER BY subdirectory DESC ) -- Set the backup command for the restore, overwrites current database with backup and moves file to Restored Folder SET @restorestring = '-SQL "RESTORE DATABASE [' + @dbname + '] FROM DISK = ''' + @restorepath + @filename + ''' WITH RECOVERY, REPLACE, MOVETO = ''C:BackupRestored''" -E' -- If a backup file exists begin the restore IF ( @filename != '' ) BEGIN EXEC master..sqlbackup @restorestring, @exitcode OUTPUT, @sqlerrorcode OUTPUT -- If an error occurred raise it IF ( @exitcode <> 0 ) OR ( @sqlerrorcode <> 0 ) BEGIN RAISERROR ( 'SQL Backup job failed with exitcode: %d SQL error code: %d', 16, 1, @exitcode, @sqlerrorcode ) END END -- Get next database FETCH NEXT FROM cDatabases INTO @dbname END -- Close cursor and drop temporary tables CLOSE cDatabases DEALLOCATE cDatabases DROP TABLE #Files DROP TABLE #sqbdir -- Create new tempory tables to store file name information CREATE TABLE #sqbdir2 ( subdirectory VARCHAR(500), Files BIT, size INT, datemodified datetime ) CREATE TABLE #Files2 ( subdirectory VARCHAR(500) ) -- Get any .sqb files still in the @restorepath folder INSERT INTO #sqbdir2 EXEC MASTER..SQBDIR @restorepath INSERT INTO #Files2 SELECT subdirectory FROM #sqbdir2 WHERE subdirectory LIKE '%.sqb' -- Create a cursor with list of .sqb files remaining and get first filename DECLARE cDatabases CURSOR FOR SELECT subdirectory FROM #Files2 OPEN cDatabases FETCH NEXT FROM cDatabases INTO @filename -- While there are files remaining @FETCH_STATUS = 0 BEGIN -- Create a tempory table and read the current backup files header information, inserting it into the table CREATE TABLE #header ( id INT IDENTITY, header VARCHAR(MAX) ) SET @restorestring = '-SQL "RESTORE SQBHEADERONLY FROM DISK = ''' + @restorepath + @filename + ''' WITH SINGLERESULTSET" -E' INSERT INTO #header EXEC MASTER..sqlbackup @restorestring -- Extract the database name from the header file SELECT @dbname = SUBSTRING(header, 23, 260) FROM #HEADER WHERE header LIKE 'Database name%' -- Check the database name doesn't currently exist on the Server, if it does not restore the file SELECT @flagg = COUNT(*) FROM sysdatabases WHERE name = @dbname IF ( @flagg = 0 ) BEGIN -- Create a temporary table to store filelist information and insert the data CREATE TABLE #FileList ( ID INT IDENTITY, LogicalName VARCHAR(200), PhysicalName VARCHAR(200), Type CHAR, FileGroupName VARCHAR(100), Size INT, MaxSize BIGINT, FileID INT, CreateLSN BIGINT, DropLSN BIGINT, UniqueID VARCHAR(36), ReadOnlyLSN INT, ReadWriteLSN INT, BackupSizeInBytes INT, SourceBlockSize INT, FileGroupID INT, LogGroupGUID VARCHAR(36), DifferentialBaseLSN BIGINT, DifferentialBaseGUID VARCHAR(36), IsReadOnly BIT, IsPresent BIT ) SET @restorestring = '-SQL "RESTORE FILELISTONLY FROM DISK = ''' + @restorepath + @filename + '''" -E' INSERT INTO #FileList EXEC master..sqlbackup @restorestring -- Get the Logical Names for the Data and Log files SELECT @ldata = LogicalName FROM #FileList WHERE TYPE = 'D' SELECT @llog = LogicalName FROM #FileList WHERE TYPE = 'L' -- Set the SQL Backup Command, this will create a new database and move the data/log files to D:Data -- If your databases generally have more data/log files script will need to be ammended for each extra file SET @restorestring = '-SQL "RESTORE DATABASE [' + @dbname + '] FROM DISK = ''' + @restorepath + @filename + ''' WITH RECOVERY, MOVE ''' + @ldata + ''' TO ''D:Data' + @dbname + '_Data.mdf'', MOVE ''' + @llog + ''' TO ''D:Data' + @dbname + '_Log.ldf'', MOVETO = ''C:BackupRestored''" -E' -- run the backup command and catch any errors EXEC master..sqlbackup @restorestring, @exitcode OUTPUT, @sqlerrorcode OUTPUT IF ( @exitcode <> 0 ) OR ( @sqlerrorcode <> 0 ) BEGIN RAISERROR ( 'SQL Backup job failed with exitcode: %d SQL error code: %d', 16, 1, @exitcode, @sqlerrorcode ) END DROP TABLE #FileList END DROP TABLE #header FETCH NEXT FROM cDatabases INTO @filename END CLOSE cDatabases DEALLOCATE cDatabases DROP TABLE #Files2 DROP TABLE #sqbdir2 / comments
For future reference, here is the script that Matt is referring to /* Creation Data : 05/11/2008 This script will look in a directory for SQL Backup .sqb files and restore the newest backup over cu...
0 votes
Hi, Thanks for your inquiry. 1. How do I only mask/obfuscate the columns I need, not the whole table? Unfortunately, the only option for masking/obfuscation is: https://documentation.red-gate.com/disp ... ata+source 2. Can I run a command line prompt with a CSV file or other formatted file that has the table and columns I need to mask, have the program load, mask the data, then do the insert into the new database? Here is a reference to the command line documentation for SQL Data Generator 3: https://documentation.red-gate.com/disp ... ine+syntax Unfortunately, there is not a way to mask/obfuscate via command line. With regards to using a CSV file with SQL Data Generator, please see the following details: The creation of the CSV file occurs outside of SQL Data Generator, therefore SQL Data Generator cannot guarantee that each value for the CSV file is unique. So when generating a CSV file to populate a column, where the column is used to establish an index, SQL Data Generator prevents you from selecting a CSV file as a generator. The question you may now ask, why can I use a CSV file as a generator source for the complete table and just not for a single column established with a unique index? When using a CSV as a generator for a table, there are additional options, for example "when data is invalid:" option whose default setting is to 'Skip row', 'Specify number of rows by' and deletion of existing data from the table before generation. Sorry for the bad news! Please let me know if you have further questions, and have a great Wednesday! Rick / comments
Hi, Thanks for your inquiry. 1. How do I only mask/obfuscate the columns I need, not the whole table? Unfortunately, the only option for masking/obfuscation is:https://documentation.red-gate.com/di...
0 votes
Hi Phil, Thanks for your inquiry and sorry to hear about your issue with SQL Backup. I will go ahead and reach out to you via the case, as it will require more back and forth to resolve. Thanks! Rick / comments
Hi Phil, Thanks for your inquiry and sorry to hear about your issue with SQL Backup. I will go ahead and reach out to you via the case, as it will require more back and forth to resolve. Thanks! Rick
0 votes
Hi Our Development team is aware of this situation, and they are actively working towards a resolve for it. Unfortunately we do not have an ETA for a fix as of yet, but, again, they are actively working on a resolution. Thanks Rick / comments
Hi Our Development team is aware of this situation, and they are actively working towards a resolve for it. Unfortunately we do not have an ETA for a fix as of yet, but, again, they are actively wo...
0 votes
Thanks for your patience with this issue. I have received an update that this issue should be resolved in the released 5.0.10 version of SQL Monitor. You can download it from here: https://www.red-gate.com/dynamic/produc ... /download# / comments
Thanks for your patience with this issue. I have received an update that this issue should be resolved in the released 5.0.10 version of SQL Monitor. You can download it from here:https://www.red-g...
0 votes