This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Run SQL query on Database server monitored with SAM

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.

  • 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.

  • Does anyone have a simple PowerShell script example?

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

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