How to determine the SQL statement used by a LANDesk query

Version 1
    Introduction

     

    Every LANDesk query is translated by the internal query engine to a SQL statement that then is sent to the database.

    Sometime we'd like to know this SQL statement: can return very handy if we'd like to understand better where the information are stored in the LANDesk database or if we want to use this statement in an external application to query the LANDesk database.

     

    How to do it

     

    First of all we need to create a LANDesk query. We can save it in My queries folder or on the Public queries folder

    Then we need to have a look to the LANDesk database at the table Query

    In this table look for the query name you just created (normally the latest record of the table contains the latest LANDesk query created) and then look at the column QuerySQL.

    This column contains the query that is sent to the database and this is exactly the statement we were looking for.

     

    Note

     

    If you are tempted now to change this field to model in different way your LANDesk query....go for it...but it will not work. This field in the table is for ''informational'' purposes only and will not influence the query that is sent to the database.

     

    Important: The SQL statement can be very long and so to be sure to be able to copy all the statement you need to configure your SQL browser to display all the text that is in the filed.

    With SQL Server 2005 Studio you may need to:

    1. Click to Tools -> Options...
    2. Browse the node Query Results -> SQL Server -> Result to Text
    3. Increase the value "Maximum number of characters displayed in each column"