PowerShell Development: Querying SQL Server

  Рет қаралды 11,969

Bryan Cafferky

Bryan Cafferky

Күн бұрын

A quick code walk through of a custom function that executes queries against a SQL Server database. Includes coverage of key concepts.
Code available at:
github.com/bca...

Пікірлер: 16
@BryanCafferky
@BryanCafferky 5 жыл бұрын
Code at: github.com/bcafferky/shared/tree/master/PowerShellSQL
@gregherbert8878
@gregherbert8878 2 жыл бұрын
very helpful, cheers Bryan!
@TarekFaham
@TarekFaham 2 жыл бұрын
That was fantastic... How can you run multiple sql statements in multiple script files using invoke sql command in powershell?
@BryanCafferky
@BryanCafferky 2 жыл бұрын
Thanks. You can run a script file using the -InputFile parameter, i.e. Invoke-Sqlcmd -InputFile "C:\ScriptFolder\TestSqlCmd.sql" See docs.microsoft.com/en-us/powershell/module/sqlserver/invoke-sqlcmd?view=sqlserver-ps For multiple files, you could loop over the file list and call Invoke-SsqlCmd
@sumitshanker2829
@sumitshanker2829 2 жыл бұрын
Could please come up with a course on using azure api using powershell.
@alex17texas
@alex17texas 5 жыл бұрын
Curious to know the benefits or draw backs of using the SQLPS module vs SQL Native client, Also if you schedule a powershell job using SQL agent, what version of powershell is sql agent using? Can you change it? Am i left to invoking powershell and passing the .ps1 file on the job step if I want to use certain cmdlets? If I loaded a function in memory would I be able to use that function in the job step and have sql agent call it given it as permission to perform said task?
@BryanCafferky
@BryanCafferky 3 жыл бұрын
Doh! Sorry but missed this until now. Not sure about the benefits of going native client but I like knowing exactly how PowerShell will connect and what it will do, i.e. not generate extra calls, or open too many threads, etc. Also, sqlps may add more than you need. The PowerShell version is determined by the SQL Server version/SQL Agent you are running. See this blog for more information. You should be able to point to a different PowerShell version by launching it from a different folder. www.sqlhammer.com/running-powershell-in-a-sql-agent-job/ A function loaded into memory by the script being executed by SQLAgent should be callable.
@michaeldobala220
@michaeldobala220 5 жыл бұрын
Very useful demonstration. Can you also demonstrante an ODBC select?
@BryanCafferky
@BryanCafferky 3 жыл бұрын
Hmmm... I think I did a video showing that but need to check. Thanks.
@DDavis0226
@DDavis0226 4 жыл бұрын
Really helpful. Thank you!
@tanmaysathaye5195
@tanmaysathaye5195 3 жыл бұрын
Can you provide the link for the code please?
@BryanCafferky
@BryanCafferky 3 жыл бұрын
Sure. I just added it to the video description too. Thanks for watching. github.com/bcafferky/shared/tree/master/PowerShellSQL
@philipadam8023
@philipadam8023 4 жыл бұрын
Very nice video. Thanks. If anyone wants the link to the file : github.com/bcafferky/shared/blob/653e8cf4d4d0aa92972d37567af2f38c9cc463d0/PowerShellSQL/Invoke-udfSQLQuery.ps1
What You Need to Know About the Amazing PowerShell Ecosystem
17:17
Bryan Cafferky
Рет қаралды 6 М.
Who’s the Real Dad Doll Squid? Can You Guess in 60 Seconds? | Roblox 3D
00:34
ТИПИЧНОЕ ПОВЕДЕНИЕ МАМЫ
00:21
SIDELNIKOVVV
Рет қаралды 1,5 МЛН
Clustered vs. Nonclustered Index Structures in SQL Server
8:04
Voluntary DBA
Рет қаралды 658 М.
PowerShell:  Creating a User Interface Lesson 1 - Quick  & Easy
28:19
Bryan Cafferky
Рет қаралды 57 М.
Professional Way Of Writing PowerShell Script for SQL DBA
32:20
Powershell Scripting Automation For SQL Server DBA
Рет қаралды 260
Introduction to Scaling Analytics Using DuckDB with Python
29:33
Bryan Cafferky
Рет қаралды 3 М.
How To Put Your SQL Server Database in Version Control (Git)
13:49
Darwin Pasco
Рет қаралды 27 М.
PowerShell Remoting
37:12
TechThoughts
Рет қаралды 72 М.
PowerShell: Writing  Functions
33:11
Bryan Cafferky
Рет қаралды 41 М.
Data Architecture vs. Data Engineering Deep Dive
33:56
Bryan Cafferky
Рет қаралды 4,6 М.
Learn to securely use Passwords with PowerShell
18:13
Shane Young
Рет қаралды 73 М.
Who’s the Real Dad Doll Squid? Can You Guess in 60 Seconds? | Roblox 3D
00:34