Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Databases with .mbf file extension

Status
Not open for further replies.

briguy00

MIS
Oct 31, 2001
1
US
Some of my users use a software program that acts as a front-end to SQL 2000 databases. The program is able to create databases but the administrator of the program has to type in the path and file name. Apparently we had a bad phone connection when I walked her through the process and she created databases with .mbf and log files with .lbf extensions. They work just fine but the anal-retentive in me wants to rename them to the recommended extensions, .mdf and .ldf. I know you can run a stored procedure to rename a database, but I haven't come across anything dealing with renaming the file extension. Does anyone know if it would work to detach the databases, change the file extension through Windows then reattach the database? Or would it be better just to leave them alone? Thanks.
 

Detach the database, rename the files and then attach using the new name. You can create and execute a script like the following.

exec sp_detach_db 'database_name'
go

--If xp_cmdshell is available... otherwise use Windows Explorer to rename the files
exec xp_cmdshell 'ren d:\mssql\data\database_name_data.mbf database_name_data.mdf'
exec xp_cmdshell 'ren d:\mssql\data\database_name_log.lbf database_name_log.ldf'
go

exec sp_attach_db @dbname = N'database_name',
@filename1 = N'd:\mssql\data\database_name_data.mdf',
@filename2 = N'd:\mssql\data\database_name_log.ldf' Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top