In this article we will observe how to invoke a video file from SQL Server using PowerShell.

Introduction

While answering to a question in DotnetFunda Forum, we came upon this question which we found to be interesting not because of the fact that we have never done it before but because of the fact we felt it will be a new adventure for us to answer this (if at all it is possible!!!). And after we answered,we felt there is a need for an article in order to write down the process for this solution/approach.Here we are presenting our approach for the same.

Requirement

Suppose we have a video file in our hard disk. How can we run/execute that one from SQL Server Management Studio(SSMS)?

Solution

The approach we took is that we are invoking the video file from the PowerShell Script and invoking that PowerShell scriptlet from SQL Server Management Studio(SSMS).Below is a step by step guidance for the same.

Step 1

Consider that we have a video file located at "D:\songs\1.mp4".Open any text editor and let us write the following command.

Start-Process -FilePath "D:\songs\1.mp4"

The purpose of the Start-Process command is to start process(s) on the local computer. The -FilePath Parameter indicates the location of the program that runs in the process.

Save the file say in our case we saved at "D:\" with the file name as "RunVideo.ps1".

Step 2

Open SSMS with "Administrative Privilege"

Step 3

Open Object Explorer by clicking on View -> Object Explorer from ToolBar or by Pressing F8

Step 4

Right click on the SSMS instance and from the PopUP window, choose Start PowerShell

Click on Start PowerShell and we will receive the below window

Type the following command in the "SQL SERVER POWERSHELL" command prompt

PS SQLSERVER:\SQL\SAMDK13050003\DEFAULT+sa\>D:\RunVideo.ps1

Hit ENTER button and enjoy the hard work

Conclusion

In this article we have seen how to invoke a video file from SQL Server using PowerShell. We hope that the article will be useful as it shows the interaction of PowerShell with SSMS. Thanks for reading.