Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Question

Author  Topic 

Trininole
Yak Posting Veteran

83 Posts

Posted - 2012-03-28 : 10:59:09
Does anyone know how to import a .bak file into SQL Server 2008?

Roger DeFour

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-03-28 : 10:59:59
what file is that ? if it is a database backup file, then use the RESTORE DATABASE command


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Trininole
Yak Posting Veteran

83 Posts

Posted - 2012-03-28 : 11:03:14
How do i go about using this restore database command?

Roger DeFour
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-03-28 : 11:11:13
since you ask that, maybe this should be easier for you

http://msdn.microsoft.com/en-us/library/ms177429%28v=sql.110%29.aspx




KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-03-28 : 11:38:23
Place the *.BAK file on the server..

Are you using SSMS (SQL Server Management Studio)?

If not You should..open a new query Window

Then


EXEC master..xp_cmdshell 'dir \\servername\instance\path\*.*'


-- Look at the internal file information
RESTORE FILELISTONLY
FROM DISK = N'\\servername\instance\path\database.BAK'
GO

-- If the DB Exists, Kick everyone out

ALTER DATABASE [database] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO

-- RESTORE The database...this will overlay an existing one, OR Create a new one if not in existence
-- Get the Logical file names from filelistonly

RESTORE DATABASE [database]
FROM DISK = N'\\servername\instance\path\database.BAK'
WITH MOVE 'logical data file' TO '\\servername\instance\datafilepath\database.MDF'
,MOVE 'logical log file' TO '\\servername\instance\datafilepath\database_log.LDF'
, REPLACE
GO

ALTER DATABASE [database] SET READ_WRITE
ALTER DATABASE [database] SET MULTI_USER
GO



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

Trininole
Yak Posting Veteran

83 Posts

Posted - 2012-03-28 : 11:39:32
Yes i am using SQL Server 2008 Management Studio!

Roger DeFour
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-28 : 12:19:02
then you've restore option available from management studio itself under tasks. Make sure .bak file is in server itself before you restore from it

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -