Backup restore script

If you need to move db's around via script, this is me trusty old script since 2000...

-- On source server...)
BACKUP DATABASE Northwind
  TO DISK = 'c:\Northwind.bak'

-- On target server.
RESTORE FILELISTONLY
  FROM DISK = 'c:\Northwind.bak'

-- look at the device names...
-- and determine where you want
-- the mdf file, and
-- the ldf file.
-- ldf files to go on the "target server"

RESTORE DATABASE TestDB
  FROM DISK = 'c:\Northwind.bak'
  WITH MOVE 'Northwind' TO 'c:\test\testdb.mdf',
  MOVE 'Northwind_log' TO 'c:\test\testdb.ldf'
GO

To get the mdf/ldf file names you can also use: sp_helpdb Northwind

Source

See also