Sunday, March 11, 2012

Database attach at setup

Hello,

Our product has a MDF file included with the setup, this needs to be attached at the current SQL Server (Express or not).
Where can we copy the MDF file during setup so it can be attached successfully ? Smile We need a place where the account SQL Server is running under has write permissions.

Please help !
Thanks

You can always use CREATE DATABASE mydb ON ( FILENAME = 'mydb.mdf')
to attach a database after installing sql server.

refer to http://msdn2.microsoft.com/en-us/library/aa258257(SQL.80).aspx for more details.

or you can do attach database via management studio

Look into this link: http://msdn2.microsoft.com/en-us/library/ms190209.aspx

|||

Embedded database feature is only available in SQL Server Express. In express, in connection string you can mention UserInstance and attach mdf file. But in all other versions, you will have to attach the database using some sqlscript explicitly. And also connection string will differ in both method

Refer this link for userinstance :

http://blogs.msdn.com/sqlexpress/archive/2006/11/22/connecting-to-sql-express-user-instances-in-management-studio.aspx

Madhu

No comments:

Post a Comment