473,387 Members | 1,611 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Sqlserver

Sir,
My question is how to attach the mdf and ldf files

regards
S.Mohanraj
Oct 16 '07 #1
2 840
debasisdas
8,127 Expert 4TB
Question moved to SQL Server forum.
Oct 17 '07 #2
iburyak
1,017 Expert 512MB
This is from help:


[PHP]sp_attach_db
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

Remarks
sp_attach_db should only be executed on databases that were previously detached from the database server using an explicit sp_detach_db operation. If more than 16 files must be specified, use CREATE DATABASE with the FOR ATTACH clause.

If you attach a database to a server other than the server from which the database was detached, and the detached database was enabled for replication, you should run sp_removedbreplication to remove replication from the database.

Permissions
Only members of the sysadmin and dbcreator fixed server roles can execute this procedure.

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

EXEC sp_attach_db @dbname = N'pubs',
@filename1 = N'c:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs.mdf',
@filename2 = N'c:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs_log.ldf'[/PHP]
Oct 17 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Martijn Rutte | last post by:
Hi, On one side, I have a Sybase 12.5 32 bits Server running on AIX 5.1 (maintenance level 3). On the other, I've got W2000 5.00.2195 (SP2) with SQL Server Standard Edition, Product Version...
7
by: Bart Torbert | last post by:
Hello, I am starting to examine using SQLServer instead of Oracle. I went through the SQLServer import utility to copy tables from Oracle into SQLServer. I then checked the size of the...
1
by: mdurliSPAMFILTER | last post by:
Hello, I developed a win32 .exe CGI that connects to a clustered SQLServer to report some data. The software is written with Borland C++Builder. This is the oledb string:...
3
by: Devonish | last post by:
I am planning to convert an existing Access database which has a back end (data tables and relationships only) on a server and a copy of the front end (form, queries, reports) on each of about a...
0
by: how can i insert a image to SQLServer? | last post by:
I want to insert some strings and images which from richTextBox into SQLServer. I could insert it into SQLServer,such as follows: FileStream s=new FileStream...
14
by: Roy Gourgi | last post by:
Hi, I need to store and retrieve information from a database. It looks as though there is a lot more support for SQLServer than there is for Access, correct me if I am wrong. What do I have...
8
by: karahan celikel | last post by:
I realized that when SqlServer mode is used for session management Session_End event is not fired in global.asax. What can I do if I want to do something when a user's session end? Thanks
0
by: UDBDBA | last post by:
Hi: We have a setup which connects a V8.2 32bit db2 instance on AIX to SQLServer 2000 using the unixODBC driver. We have 5 SQLServer "Server mappings" and 4 of them work just fine and can use...
2
by: Jenniflower | last post by:
Hi Gurus, Our system is using SqlServer 2005 on XP.( On my machine,only this application access SQLServer.) The sqlserver memory is configured to 128MB (Min)~512 MB(Max) After our system get...
7
by: Academia | last post by:
I was told that SqlServer express should get installed when VS2008Pro is installed (that is it is on the same DVD). I had a couple of errors during vs2008's installation and I don't see any...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.