bhai jaan mear SQL server cruppet ho gya tha jo k me ne reinstal ker liya he abb data bhee creat kerli he abb files ko attech keasay kerwain gay plz help me with Sneps...
bhai jaan mear SQL server cruppet ho gya tha jo k me ne reinstal ker liya he abb data bhee creat kerli he abb files ko attech keasay kerwain gay plz help me with Sneps...
To Attach a Database File
Open the command prompt on the server.
From the command prompt, connect to an instance of SQL Server by using the following sqlcmd command:
Copy Code
Where Server is the name of the computer and Instance is the name of the instance.sqlcmd -S Server\Instance
When connected, type the following commands:
Copy Code
Where database_name is the name of the database you want to attach, FileName is the path and filename of the database file and the log file, and FOR ATTACH specifies that the database is created by attaching an existing set of operating system files.USE [master]
GO
CREATE DATABASE [database_name] ON
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\Data\<database name>.mdf' ),
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\Data\<database name>.ldf' )
FOR ATTACH ;
GO
To verify that the database has been attached, type the following two commands:
Copy Code
The sqlcmd tool displays the names of all databases attached to this instance of SQL Server Express. In the list, you should see the database name you provided in step 3select name from sys.databases
go.
2nd method....
To attach a database
Right-click Databases, point to Tasks, and then click Attach.
In the Attach Databases dialog box, to specify the database to be attached, click Add; and in the Locate Database Files dialog box, select the disk drive where the database resides and expand the directory tree to find and select the .mdf file of the database; for example:
C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\AdventureWor ks_Data.mdf
Important:
Trying to select a database that is already attached generates an error.
Optionally, to specify a different name for the database to attach as, enter the name in the Attach as column of the Attach Databases dialog box.
Optionally, change the owner of the database by selecting a different entry in the Owner column.
When you are ready to attach the database, click OK.
Bookmarks