Question

I want to attach SQL Server 2005 database at runtime.

Can this be achieved without using local instance of SQL Server i.e. even without SQL Server Express?

Currently I'am using following connection string is there any other workaround.

Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf; Database=dbname;Trusted_Connection=Yes;

Thanks, Lalit

Was it helpful?

Solution

No, the 'runtime attach' is an Express only feature, see SQL Server 2005 Express Edition User Instances.

On a non-express SQL instance you you ask your DBA to attach the database properly. He knows how to do it, via: sp_attach_db. Attaching a database has many implications on security, storage allocation, I/O patterns etc and applications should not attach databases themselves. Use an Express edition if you want the 'runtime attach' like behavior.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top