cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post
Level 9

Run SQL query on Database server monitored with SAM

Jump to solution

How can I execute a query (on a server monitored in SAM) and get back the results from it displayed somewhere in SAM?

TNX in advance.

0 Kudos
1 Solution
Level 9

Well guys I got it

Found everything I need here: The Basics of PowerShell (part 3)

View solution in original post

0 Kudos
4 Replies
Level 9

Well guys I got it

Found everything I need here: The Basics of PowerShell (part 3)

View solution in original post

0 Kudos
Level 12

The links in this thread no longer work.
I am trying to do the same with Powershell

0 Kudos
Level 9

Does anyone have a simple PowerShell script example?

Connect to database, execute query and view results. Maybe you jorich ?

0 Kudos
Level 10

petart​ - I use two methods for querying SQL into SAM. 

  1. SQL User experience monitor
    1. The SQL User experience monitor is straight-forward to set up, but limited in that it wants the SQL query you run against your monitored DB to return just one row containing a "Statistic" (number) - and alternately a "Message" (text) as the results of the query.   It's great for validating the SQL server is handling queries, and how long it's taking to run them, but can be limiting otherwise.  It's not designed to focus as much one the data returned, as the fact it is being returned.  Still, a clever query can get you a result in those two metric/message fields that can be useful.
  2. Powershell (or VB) monitor
    1. In a Powershell monitor you can connect to your database using powershell scripting, and return up to 10 metric/message pairs.  It's not as limiting in that you can return more points of data to the monitor than just one, but you'll need to know how to write that script, and then learn the idiosyncrasies of returning and presenting data in the Powershell monitor.  It's a very flexible tool, but a little daunting in some cases.

Aside from viewing the results in the monitor's Application page, either of these methods lets you display the results in a Custom Object Resource element (again, not intuitive to learn, but doable and and excellent tool in your belt) or alternately a Custom SWQL element (ditto!)

Love to hear how others are handling this.