![psn stuff x custom database psn stuff x custom database](https://2img.net/u/3214/31/00/56/avatars/1-17.jpg)
This command connects to a named instance of the SQL Database Engine on a computer and runs a basic Transact-SQL script. Examples Example 1: Connect to a named instance and run a script PS C:\> Invoke-Sqlcmd -Query "SELECT GETDATE() AS TimeOfQuery" -ServerInstance "Måomputer\MainInstance" You can display SQL Server message output, such as those that result from the SQL PRINT statement, by specifying the Verbose parameter. If subsequent result sets after the first set have the same column list, their rows are appended to the formatted table that contains the rows that were returned by the first result set.
![psn stuff x custom database psn stuff x custom database](https://i.pcmag.com/imagery/lineupitems/00kI9gI0dyvdvIYQwYcyrYt.fit_lim.size_1050x578.v1569506711.jpg)
If subsequent result sets contain different column lists than the first, those result sets are not displayed. When this cmdlet is run, the first result set that the script returns is displayed as a formatted table. The commands not supported include :!!, :connect, :error, :out, :ed, :list, :listvar, :reset, :perftrace, and :serverlist. This cmdlet does not support the use of commands that are primarily related to interactive script editing. By default, this cmdlet does not set SQLCMD scripting variables. This cmdlet also accepts the SQLCMD scripting variables, such as SQLCMDUSER. This cmdlet also accepts many of the commands supported natively by SQLCMD, such as GO and QUIT. The commands supported are Transact-SQL statements and the subset of the XQuery syntax that is supported by the database engine. The Invoke-Sqlcmd cmdlet runs a script containing the languages and commands supported by the SQL Server SQLCMD utility.
![psn stuff x custom database psn stuff x custom database](http://mas.txt-nifty.com/.shared/image.html?/photos/uncategorized/2009/09/13/2009091303.jpg)
Runs a script containing statements supported by the SQL Server SQLCMD utility.