About 595,000 results
Open links in new tab
  1. How do you run a SQL Server query from PowerShell?

    There isn't a built-in "PowerShell" way of running a SQL query. If you have the SQL Server tools installed, you'll get an Invoke-SqlCmd cmdlet. Because PowerShell is built on .NET, you can use the ADO.NET API to run your queries.

  2. Invoke-Sqlcmd (SQLServer) - SQL Server PowerShell

    The Invoke-Sqlcmd cmdlet runs a script containing the languages and commands supported by the SQL Server SQLCMD utility. The commands supported are Transact-SQL statements and the subset of the XQuery syntax that is supported by the database engine.

  3. Run SQL Query in PowerShell: A Quick Guide

    This guide demonstrated how to effectively run SQL queries in PowerShell, from connecting to a SQL Server instance to executing various commands, including SELECT, INSERT, UPDATE, and DELETE operations.

  4. Generating SQL Scripts using Windows PowerShell

    Sep 22, 2009 · In this tip I will cover how to generate scripts using Windows PowerShell. SQL scripting in SMO is controlled either by the Scripter object and its child objects, or the Script method on individual objects as highlighted in the previous tip. We will be using the same approaches to generate SQL scripts using Windows PowerShell.

  5. Working with PowerShell’s Invoke-SqlCmd - SQL Shack

    Mar 18, 2019 · As we’ve seen, PowerShell’s Invoke-SqlCmd is a convenient tool in which we can create objects, read and write data to and from SQL Server (with direct or file input), and save queries to files without significant development work.

  6. SQL Server and PowerShell: Practical Examples - Octopus Deploy

    Nov 26, 2019 · My goal in this post, is to provide some common examples of SQL Server database management with PowerShell to make integration into deployments much more straightforward. The source for all of these examples is available on GitHub.

  7. Run a SQL Script from PowerShell: A Quick Guide

    You can execute a SQL script from PowerShell by utilizing the `Invoke-Sqlcmd` cmdlet, which allows you to run Transact-SQL commands directly against a SQL Server instance. Here's a code snippet to demonstrate how to run a SQL script: Invoke-Sqlcmd -ServerInstance "YourServerName" -Database "YourDatabaseName" -InputFile "C:\Path\To\Your\Script.sql"

  8. Create SQL Server Database with PowerShell

    Nov 12, 2019 · Let’s look at two ways to use the Invoke-SqlCmd cmdlet which is very similar to the sqlcmd.exe utility. The first way will call a SQL script using the -InputFile switch which is the equivalent of sqlcmd’s -i switch. Paste the SQL code below into a file in C:\scripts called Create_MyDatabase.sql. CONTAINMENT = NONE. ON PRIMARY . LOG ON .

  9. Getting Started with PowerShell Invoke-SQLCmd Command

    Apr 3, 2023 · With the Invoke-SqlCmd cmdlet, you can execute SQL queries and scripts within a PowerShell console. As a result, you can automate database management tasks and integrate SQL Server with other PowerShell commands and modules.

  10. Execute SQL Server Stored Procedures from PowerShell

    Mar 18, 2019 · We can create a PowerShell function to execute a stored procedure and read the output, or we use Invoke-SqlCmd for the same purpose. In this tip, we’ll do both to show alternatives.

  11. Some results have been removed
Refresh