I am writing a powershell script that will automate a dev environment deployment and I've hit a problem with attaching the db's. I am adding the 2 snap ins SqlServerCmdletSnapin100 and SqlServerProviderSnapin100 and using SQLSERVER:\SQL\localhost\SQLEXPRESS and the AttachDatabase method. This is working well and if I use DetachDatabase method in the same way I can re-run the script continually. My problem arises when I detach from the management studio and try to run the script again. No matter what I do here (permissions etc.) the script will continually fail from this point on with error:
Exception calling "AttachDatabase" with "2" argument(s):
"Attach database failed for Server 'localhost\SQLEXPRESS'. "
If I change the name of the database I am attaching as the script will work again. Is there something in a system db that would be hanging onto the Database or database files that I need to remove as well?
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)