in Education by
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)

1 Answer

0 votes
by
SMO uses nested error objects, so I'm wondering what the base error message states. If you run this statement: $error[0] | fl -force What error message do you get Update Ran a quick test: Detach database "hsg" from my local instance using SSMS and successfully attached with this script: PS SQLSERVER:\SQL\WIN7BOOT\SQL1> $s = get-item . PS SQLSERVER:\SQL\WIN7BOOT\SQL1> $s.AttachDatabase("hsg",$sc) PS SQLSERVER:\SQL\WIN7BOOT\SQL1> $sc = new-object System.Collections.Specialized.StringCollection PS SQLSERVER:\SQL\WIN7BOOT\SQL1> $sc.Add("C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQL1\MSSQL\DATA\hsg.mdf") PS SQLSERVER:\SQL\WIN7BOOT\SQL1> $sc.Add("C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQL1\MSSQL\DATA\hsg_log.ldf)

Related questions

0 votes
    I've got a local .mdf SQL database file that I am using for an integration testing project. Everything ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
0 votes
    ____________ allow its users to attach to the internet via a remote or virtual server which preserves privacy. ... -Cyber Security:,Cyber Security-Jobs:,Cyber Security Applications...
asked Nov 1, 2021 in Education by JackTerrance
0 votes
    I have an old server with a defunct evaluation version of SQL 2000 on it (from 2006), and two ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    I have an old server with a defunct evaluation version of SQL 2000 on it (from 2006), and two ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    The type of malware that tricks users by making them believe that their computer has been infected with a virus is called ... . (1)Spyware (2)Ransomware (3)Scareware (4)Rootkits...
asked Mar 22, 2021 in Technology by JackTerrance
0 votes
    By default sql server has ___________ isolation level (a) READ COMMITTED (b) READ UNCOMMITTED (c) ... Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    By default sql server has ___________ isolation level (a) READ COMMITTED (b) READ UNCOMMITTED (c) ... Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    This is a question I asked on another forum which received some decent answers, but I wanted to see ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 24, 2022 in Education by JackTerrance
0 votes
    The __________________ contains a list of pages that have been updated in the database buffer. (a) Dirty ... , Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    The __________________ contains a list of blocks that have been updated in the database buffer. (a) ... Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    Before a block of data in main memory can be output to the database, all log records pertaining to ... Buffer Management topic in chapter Recovery System of Database Management...
asked Oct 10, 2021 in Education by JackTerrance
0 votes
    I have a self hosted gitlab on ubuntu machine. I configure a linux container for it to run runner. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 22, 2022 in Education by JackTerrance
0 votes
    I try to create database from entity framework code first follow with this tutorial http://www.asp.net/mvc ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    I'm currently developing a web application using asp.net c#. I got a server where I today was ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 12, 2022 in Education by JackTerrance
0 votes
    Which of the following attach is not used by LC4 to recover Windows password? (a) Brute-force attack (b) ... Security questions and answers pdf, mcq on Cyber Security pdf,...
asked Nov 3, 2021 in Education by JackTerrance
...