please explain me where i have asked you couple of question
thanks for the script buddy.
Code:
SELECT @@SERVERNAME //here i should write my database name or server name ?
-- ***
-- *** Make Sure the Server Name is
-- ***
-- Find the Database file to Restore. Make sure it's on the Server
EXEC master..xp_cmdshell 'dir \\servername\instance\path\*.*' //what is happening here
-- 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'
// i didnt find any thing like this , i mean where this .ldf file is stored in ms sql folder
, REPLACE
GO
ALTER DATABASE [database] SET READ_WRITE
ALTER DATABASE [database] SET MULTI_USER
GO