f2s_mssql_attach_db¶
Applies to: MS SQL
Syntax
f2s_mssql_attach_db {database} on {filePath}
Parameter |
Description |
---|---|
database |
Name of the database |
filePath |
Path of the MDF file to attach |
Description
The f2s_mssql_attach_db command is intended for use with our new support of Microsoft LocalDB’s. When using LocalDB’s a common use case might be to attach to a customer DB, do some work on it, and then detach this DB and attach to a different DB. This was possible using stored procedures, but the code had some complexities that a developer need not worry about. When you attach a database, you must pass the database name, along with the path to an MDF file which contains the database. Any associated LDF’s (log files) and NDF’s (secondary data files) must be in the same folder.
If you call f2s_mssql_attach_db on a database that is already attached, no error will be generated. After you call f2s_mssql_attach_db, you should call SET_DATABASE_NAME if you wish to make the attached database the currently selected database.
f2s_mssql_attach_db will work on all supported version of SQL server.
Example
f2s_mssql_attach_db "MTSample" ON "C:\Mertech\Data\SampleDb.mdf"
Related Commands
f2s_mssql_detach_db
Replaces: SQLSERVER_DETACH_DB