Tuesday, April 5, 2011

Restore MS SQL Server Backup file

Recently I was faced with a dilemma - a friend of mine had a M$ SQL Server backup file and wanted me to extract some data from it. Since I work on Ubuntu & LAMP stack, I had to grab hold of a Win7 laptop and then follow the below steps.

To restore a database you need to do three things:
  1. Install MS SQL Server Express
  2. Interrogate the backup file to find the logical file names it contains
  3. Restore the file into the appropriate database

Assume: For this example, the backup file is C:\Backups\DB_Backup_20110131.bak

Step 1: Install MS SQL Server
Go to Micro$oft site using the direct link http://www.microsoft.com/express/Database/I-nstallOptions.aspx and download and install the most appropriate version of SQL Server Express.

Step 2: Interrogate Backup File
RESTORE FILELISTONLY FROM DISK = 'C:\Backups\DB_Backup_20110131.bak'

This will return something like the below set of rows which represent the internal logical composition of the backup file:

LogicalName        PhysicalName                 Type FileGroupName Size      MaxSize
------------------ ---------------------------- ---- ------------- --------- --------------
SourceDatabase_data C:\SqlServer\Src_DB_Data.mdf D    PRIMARY       836461765 35184372080640
SourceDatabase_log  C:\SqlServer\Src_DB_Log.ldf  L    NULL           91592723 35184372080640

Step 3: Restore from Backup File

RESTORE DATABASE Destination_DB
FROM DISK = 'C:\Backups\DB_Backup_20110131.bak'
WITH 
     REPLACE, -- Overwrite DB - if one exists
     RECOVERY, -- Use if this is the only file to recover
     STATS = 10, -- Show progress (every 10%)
     MOVE 'SourceDatabase_data' TO 'C:\SqlServer\Src_DB_Data.mdf', 
     MOVE 'SourceDatabase_log' TO 'C:\SqlServer\Src_DB_Data.mdf'

Array Equality in JUnit

Till JUnit4.2.*, the only way to compare equality of arrays was to use the following snippet of code:

assertTrue(java.util.Arrays.equals(primitiveArray1, primitiveArray2));

JUnit4.3.* added the assertArrayEquals methods but surprisingly omitted a method to compare arrays of primitive doubles so, one had to fall back to the above mentioned way to compare them.

This important feature was added in JUnit4.6 so if you are using that or a later version, you can do the following:
assertArrayEquals(doubleArray1, doubleArray2, delta)
where delta is the allowed tolerance.

The advantage with using the assertArrayEquals method over the previous method is that this method clearly indicates the first element which differed. For example, when the below basic test is run, it gives the error message:
arrays first differed at element [2]; expected:<2.3124> but was:<2.3224>

Here is a sample class file showing implementation of the above test:

import static org.junit.Assert.assertArrayEquals;
import org.junit.Test;

public class AAETest {

    @Test
    public void testAAEDouble() {
     double[] da1 = {1.002d, 1.234d, 2.3124d, 3.91293d};
     double[] da2 = {1.003d, 1.2345d, 2.3224d, 3.91293d};
     double tol = 0.001d;
     assertArrayEquals(da1, da2, tol);
    }
}

Comparison of Intel Atom processors

With the various Atom Processor based netbooks and nettops being available these days, it becomes very difficult to decide which one to go for. Searching for the differences between the processors, I found the following comparison chart:

Product NameMax TDPCores /
Threads
Intel® VT-xIntegrated
Graphics
Intel® Turbo Boost
Technology
Status
Intel® Atom™ Processor Z560
(512K Cache, 2.13 GHz, 533 MHz FSB)
2.5 Watts1C / 2TYes   NoLaunched
Intel® Atom™ Processor Z550
(512K Cache, 2.00 GHz, 533 MHz FSB)
2.4 Watts1C / 2TYes   NoLaunched
Intel® Atom™ Processor Z540
(512K Cache, 1.86 GHz, 533 MHz FSB)
2.4 Watts1C / 2TYes   NoLaunched
Intel® Atom™ Processor Z530P
(512K Cache, 1.60 GHz, 533 MHz FSB)
2.2 Watts1C / 2TYes   NoLaunched
Intel® Atom™ Processor Z530
(512K Cache, 1.60 GHz, 533 MHz FSB)
2 Watts1C / 2TYes   NoLaunched
Intel® Atom™ Processor Z520PT
(512K Cache, 1.33 GHz, 533 MHz FSB)
2.2 Watts1C / 2TYes   NoLaunched
Intel® Atom™ Processor Z520<
(512K Cache, 1.33 GHz, 533 MHz FSB)
2 Watts1C / 2TYes   NoLaunched
Intel® Atom™ Processor Z515
(512K Cache, 1.20 GHz, 400 MHz FSB)
1.4 Watts1C / 2TNo   NoLaunched
Intel® Atom™ Processor Z510PT
(512K Cache, 1.10 GHz, 400 MHz FSB)
2.2 Watts1C / 2TNo   NoLaunched
Intel® Atom™ Processor Z510P
(512K Cache, 1.10 GHz, 400 MHz FSB)
2.2 Watts1C / 2TNo   NoLaunched
Intel® Atom™ Processor Z510
(512K Cache, 1.10 GHz, 400 MHz FSB)
2 Watts1C / 1TNo   NoLaunched
Intel® Atom™ Processor Z500
(512K Cache, 800 MHz, 400 MHz FSB)
0.65 Watts1C / 2TNo   NoLaunched
Intel® Atom™ Processor N570
(1M Cache, 1.66 GHz)
8.5 Watts2C / 4T       Launched
Intel® Atom™ Processor N550
(1M Cache, 1.50 GHz)
8.5 Watts2C / 4TNoYesNoLaunched
Intel® Atom™ processor N475
(512K Cache, 1.83 GHz)
6.5 Watts1C / 2TNoYesNoLaunched
Intel® Atom™ Processor N470
(512K Cache, 1.83 GHz)
6.5 Watts1C / 2TNoYesNoLaunched
Intel® Atom™ processor N455
(512K Cache, 1.66 GHz)
6.5 Watts1C / 2TNoYesNoLaunched
Intel® Atom™ Processor N450
(512K Cache, 1.66 GHz)
5.5 Watts1C / 2TNoYesNoLaunched
Intel® Atom™ Processor N280
(512K Cache, 1.66 GHz, 667 MHz FSB)
2.5 Watts1C / 2TNo   NoLaunched
Intel® Atom™ Processor N270
(512K Cache, 1.60 GHz, 533 MHz FSB)
2.5 Watts1C / 2TNo   NoLaunched
Intel® Atom™ Processor E680T
(512K Cache, 1.60 GHz)
4.5 Watts1C / 2TYesYesNoLaunched
Intel® Atom™ Processor E680
(512K Cache, 1.60 GHz)
4.5 Watts1C / 2TYesYesNoLaunched
Intel® Atom™ Processor E665CT
(512K Cache, 1.3 GHz)
7 Watts1C / 2TYesYes   Launched
Intel® Atom™ Processor E665C
(512K Cache, 1.3 GHz)
7 Watts1C / 2TYesYes   Launched
Intel® Atom™ Processor E660T
(512K Cache, 1.30 GHz)
3.6 Watts1C / 2TYesYesNoLaunched
Intel® Atom™ Processor E660
(512K Cache, 1.30 GHz)
3.6 Watts1C / 2TYesYesNoLaunched
Intel® Atom™ Processor E645CT
(512K Cache, 1.0 GHz)
7 Watts1C / 2TYesYes   Launched
Intel® Atom™ Processor E645C
(512K Cache, 1.0 GHz)
7 Watts1C / 2TYesYes   Launched
Intel® Atom™ Processor E640T
(512K Cache, 1.00 GHz)
3.6 Watts1C / 2TYesYesNoLaunched
Intel® Atom™ Processor E640
(512K Cache, 1.00 GHz)
3.6 Watts1C / 2TYesYesNoLaunched
Intel® Atom™ Processor E625CT
(512K Cache, 600 MHz)
7 Watts1C / 2TYesYes   Launched
Intel® Atom™ Processor E625C
(512K Cache, 600 MHz)
7 Watts1C / 2TYesYes   Launched
Intel® Atom™ Processor E620T
(512K Cache, 600 MHz)
3.3 Watts1C / 2TYesYesNoLaunched
Intel® Atom™ Processor E620
(512K Cache, 600 MHz)
3.3 Watts1C / 2TYesYesNoLaunched
Intel® Atom™ processor D525
(1M Cache, 1.80 GHz)
13 Watts2C / 4TNoYesNoLaunched
Intel® Atom™ Processor D510
(1M Cache, 1.66 GHz)
13 Watts2C / 4TNoYesNoLaunched
Intel® Atom™ processor D425
(512K Cache, 1.80 GHz)
10 Watts1C / 2TNoYesNoLaunched
Intel® Atom™ Processor D410
(512K Cache, 1.66 GHz)
10 Watts1C / 2TNoYesNoLaunched
Intel® Atom™ Processor 330
(1M Cache, 1.60 GHz, 533 MHz FSB)
8 Watts2C / 4TNo   NoEnd of Life
Intel® Atom™ Processor 230
(512K Cache, 1.60 GHz, 533 MHz FSB)
4 Watts1C / 2TNo   NoEnd of Life

This is taken from the Intel Ark site.

Now based on the above table, the decision making process is slightly easier!

LinkWithin

Related Posts Plugin for WordPress, Blogger...