Thursday, August 13, 2015

Executing SQL from PowerShell

For some reason when I upgraded to SQL Server 2012, SSMS boots very slowly. Well, if I want to just execute a quick query I don't want to have to wait. Programmers don't do well when they have to wait for results :). I always have Powershell ISE open, so I figured being able to execute SQL queries from that would be nice and efficient.

Solution
$sql = "SELECT * FROM Table"
Invoke-Sqlcmd -Query $sql -ServerInstance "server\instance" -Database "database" | ft



Refhttp://t.co/L5JRBpg5Fu 

No comments:

Post a Comment

There was an error in this gadget