From the course: SQL Server 2012: Designing Database Solutions
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Using Windows PowerShell to run SQL commands - SQL Server Tutorial
From the course: SQL Server 2012: Designing Database Solutions
Using Windows PowerShell to run SQL commands
- In this section, I'd like to talk about using powershell to run queries against our SQL Server 2012 databases. I'm gonna go to the start menu, type in powershell and open up the Windows powershell command. Sometimes, I like to adjust the size of the powershell window. If you right-click in the title bar and go to Properties, you'll have the option to change the font. First thing I'll need to do is load the SQL powershell commands. So, that is import-module and in the quotes, sqlps and I'll probably get a warning about the Analysis Services again. Not a problem. Not going to affect what I'm trying to accomplish here. Now, in order to issue a traditional SQL command, I'll need to first enter the powershell command, Invoke-SQLcmd. Then, we'll need to say -Query to specify that we are running a query and in quotes, we'll go ahead and type out our query. I'd like to do a SELECT * from a table in the Adventure Works database. When I type in the name of the table, I'm going to need to…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.