How do I attach an external SQL Server DB

Asked By 0 points N/A Posted on -
qa-featured

Hi,

One of my friend has given me a Microsoft SQL Database.

How can I attach it to my database server.

The files I got are as follows.

myproject1.mdf

Can you please put down all the steps how to attach this DB?

Thanks,

Cameron

SHARE
Best Answer by Vinson forman
Answered By 0 points N/A #124176

How do I attach an external SQL Server DB

qa-featured

sp_attach_db system stored procedure can be used to attach a database with the following syntax:

sp_attach_db [ @dbname = ] 'dbname',
             [ @filename1 = ] 'filename_n' [ ,…16 ]

sp_attach_single_file_db system stored procedure can be used, to attach a single file with this syntax:

sp_attach_single_file_db [ @dbname = ] 'dbname'
    , [ @physname = ] 'physical_name' 

@dbname is the name of the database while @physname is the database file name.

Best Answer
Best Answer
Answered By 0 points N/A #196792

How do I attach an external SQL Server DB

qa-featured

Hello Cameron,

Thanks for sharing your problem with us on this growing information technology website.

Dear it is so easy to attach a new file you have downloaded or got from friend.

Just type these codes with the same syntax,

sp_attach_single_file_db [ @dbname= ] 'dbname'     , [ @physname= ] 'physical_name' Arguments: Here, (@dbname)'physical_name' is the name of the file which you want to attach or upload to the SQL Server. And (@physname) Is also the name of file but with the complete location or address of the file.

When you will finish this step you will get return codes value.

If you got 0 it means the process was successful, if you got 1 it represent of a failure.

Thanks i hope you are satisfied on this solution.

Related Questions