How to attach a DB to SQL Server ?
-
Hello, Im using this following softwares: VS 2008 & Microsoft SQL Server 2005 I want to attach my database to SQL Server. How can I do this(Without using wizard) ? TIA
comp_j wrote:
Im using this following softwares: VS 2008 & Microsoft SQL Server 2005 I want to attach my database to SQL Server. How can I do this(Without using wizard) ?
How does it related with ASP.NET ? If you have to ask it on General DB Forum.
comp_j wrote:
How can I do this(Without using wizard) ?
Why you want to avoid Wizard ? Do you want to do it programmatically.?
Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.
-
comp_j wrote:
Im using this following softwares: VS 2008 & Microsoft SQL Server 2005 I want to attach my database to SQL Server. How can I do this(Without using wizard) ?
How does it related with ASP.NET ? If you have to ask it on General DB Forum.
comp_j wrote:
How can I do this(Without using wizard) ?
Why you want to avoid Wizard ? Do you want to do it programmatically.?
Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.
-
Hello, Im using this following softwares: VS 2008 & Microsoft SQL Server 2005 I want to attach my database to SQL Server. How can I do this(Without using wizard) ? TIA
Connect to master Database using your .NET object. Then run the stored procedure below :
EXEC sp_attach_db @dbname = 'dbname',
@filename1 = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\dbname.mdf',
@filename2 = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\dbname_log.LDF'Please replace the path to the existing mdf and ldf files. You can also create using
CREATE DATABASE [dbname] ON
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\dbname.mdf' ),
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\dbname_log.LDF' )
FOR ATTACH
GOcommand Hope you can do this now.
Abhishek Sur
My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB
**Don't forget to click "Good Answer" if you like to.