You can use a stored procedure; from the TPAM System Administrator Guide in the Ticket System Management section:
SQL Command:
Enter a simple SELECT query or execute a stored procedure to return a
single row result set. Substitution parameters may be entered in the
command using :param: syntax. Oracle databases only support SELECT
type syntax, no EXEC stored procedure for a result set. SQL Server
supports SELECT and EXEC. Case sensitivity is controlled by the target
database. The SELECT and EXEC statement must be written to produce
a result set of exactly one row if successful. When validating ticket
numbers for requests a results set of zero rows or more than one row is
considered as a failed validation.
NOTE: This command is executed against the target database. Please
ensure that the database login has proper safeguards to prevent
accidental or intentional loss of data.