Discussion Locked

database files

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have two database files, inv.mdf and inv.ldf, from MSSQL Server 2000 that is dead. I used windows explorer to locate the aforementioned files in the Data folder.

I have installed a new instance of the MSSQL Server 2000 on a different computer and copied the inv.mdf and inv.ldf to the hard drive of this new installation. How can I import/copy the two files into the new instance of the MSSQL Server in order to create a database called inv?

3 replies

by rock tremblay

sp_attach_db (T-SQL)
Attaches a database to a server.

Syntax
sp_attach_db [@dbname =] 'dbname',
[@filename1 =] 'filename_n' [,...16]

Arguments
[@dbname =] 'dbname'
Is the name of the database to be attached to the server. The name must be unique. dbname is sysname, with a default of NULL.

[@filename1 =] 'filename_n'
Is the physical name, including path, of a database file. filename_n is nvarchar(260), with a default of NULL. There can be up to 16 file names specified. The parameter names start at @filename1 and increment to @filename16. The file name list must include at least the primary file, which contains the system tables that point to other files in the database. The list must also include any files that were moved after the database was detached.
Return Code Values
0 (success) or 1 (failure)

Result Sets
None
-------------------------------------------

Examples
This example attaches two files from pubs to the current server.

EXEC sp_attach_db@dbname = N'pubs',
@filename1 = N'c:\mssql7\data\pubs.mdf',
@filename2 = N'c:\mssql7\data\pubs_log.

Source: SQL Server 7.0 Books Online

by setivi

The solution will only work for a database that was
previously detached. The database in question went down when the Operating System went down.

This discussion is closed to new replies.