I'm super lazy so I'm spending hours writing a batch file to handle restoring a database to a sql server and making a whole bunch of changes to it after that happens.
Different people send me the databases that I'm using.
I only need the database and the transaction log, skipping any other files. Currently the following works for most of the databases I have.
This part is in the batch.
SQLCMD -S %SName% -U %UName% -P %Pwd% -v varDBName=%DBName% varDBPath=%1 varSQLLogPath=%SQLLogPath% varSQLDataPath=%SQLDataPath% -i "%RunningPath%\RestoreScript.sql" -o "%RunningPath%\Restore_Log.txt"
This is the restore script I'm calling.
RESTORE DATABASE [$(varDBName)] FROM DISK = N'$(varDBPath)' WITH FILE = 1, MOVE N'MQ1CS_Data' TO N'$(varSQLDataPath)\$(varDBName).MDF', MOVE N'MQ1CS_Log' TO N'$(varSQLLogPath)\$(varDBName).LDF', NOUNLOAD, REPLACE, STATS = 10
The problem I just ran into is that the database I'm trying to restore has a third file, something called sysFT_OpenIssuesFT. I'm guessing the filename on this changes depending on how the DBA sets it up. Is there a way to only restore the above two files? Will the database work without this third full text file?
How can I write that SQL script so that only the data and log files get restored up and nothing else?