With PowerShell, we can easily create databases in batches. The following describes in detail: for example, if we want to create three databases at a time, their names are DB1, DB2, DB3, we can create a text file, for example, the file name is DBs, And the content is the list of database names to be created: Next, we can use the following cm
With PowerShell, we can easily create databases in batches. The following describes in detail: for example, if we want to create three databases at a time, their names are DB1, DB2, DB3, we can create a text file, for example, the file name is DBs, And the content is the list of database names to be created: Next, we can use the following cm
With PowerShell, you can easily create databases in batches. The following describes in detail:
For example, if we want to create three databases at a time, whose names are DB1, DB2, and DB3, we can create a text file. For example, the file name is DBs, the content is a list of database names to be created:
Next, we can use the following cmdlet to achieve our goal:
$ List = get-content D: \ DBs.txt echo $ list | ForEach-Object {Invoke-SqlCmd-Query "create database $ _"}
After the execution, refresh the SSMS database. The three databases have been created. OK:
For the context warning of the above provider, we can use-SuppressProviderContextWarning to disable the warning information (the following command ), you can also use the-IgnoreProviderContext parameter to notify Invoke-Sqlcmd to always use the default database of the Logon account.
$ List | ForEach-Object {Invoke-SqlCmd-Query "create database $ _"-SuppressProviderContextWarning}