Answered step by step
Verified Expert Solution
Question
1 Approved Answer
try { < # Create Database # > Write - Host - ForegroundColor Cyan [ SQL ] : Starting SQL Tasks # Import SqlServer
try
# Create Database #
WriteHost ForegroundColor Cyan SQL: Starting SQL Tasks"
# Import SqlServer Module
ifGetModule Name sqlpsRemoveModule sqlps
ImportModule Name SqlServer
# D: Check for the existence of the database
$serverName SRVPRIMARYSQLEXPRESS
$databaseName "MyDatabaseNetObjects"
# Create connection to server
$connectionString "Data Source$$serverName; Initial Catalogmaster;Integrated SecurityTrue;"
$sqlConnection NewObject System.Data.SqlClient.SqlConnection
$sqlConnection.ConnectionString $connectionString
$sqlConnection.Open
# Create query to detect if database exists
$detectQuery "Select name FROM sysdatabases WHERE name $$databaseName
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started