0

I would like to send a Telnet command or start a *.bat file when I get a result in a SQL view. I am using SQL Express and so don't have the SQL Server Agent.

I am trying to launch a cue in a lighting software, 30 minutes before one of our shows starts. The software listens to Telnet commands or bat files.

Could anyone suggest a free software of a way to do this from within SQL Express Server thru SSMS?

Thanks in advance,

bregtV
  • 9
  • 3
  • 1
    This makes no sense at all. You want to send a Telnet command when something selects from a view and the view has results? This sounds like an [XY Problem](http://xyproblem.info/) What are you really trying to accomplish? – Sean Lange Oct 30 '19 at 16:21
  • A `VIEW` is simply a pre-written `SELECT` statement. It's a Virtual Table. It can't send a TelNet command; it's not a CLR Function/Store Procedure. – Thom A Oct 30 '19 at 16:28

1 Answers1

0

I think the best option you have is to use Windows Task Scheduler. Create a PowerShell script that selects the records from your View and if the count is greater than 0 launch the .bat file .

Example :

$query = "SELECT * FROM MY_VIEW"
$results = Invoke-Sqlcmd -ServerInstance "yourserver\instance" -Database "yourdatabase" -Username "username" -Password "password" -Query $query
if ($results.Count() -gt 0){
    C:/path_to_bat_file.bat
}

Links :

https://learn.microsoft.com/en-us/powershell/module/sqlserver/invoke-sqlcmd?view=sqlserver-ps

https://learn.microsoft.com/en-us/powershell/module/nettcpip/test-netconnection?view=win10-ps

FidelCasto
  • 176
  • 2
  • 15