ServiceDesk

 View Only
  • 1.  Can you use variables in report SQL

    Posted Nov 09, 2011 05:24 PM

    If I was to write my own SQL statement in a report, would I be able to use variables?  ie I want to use a date variable in the SQL where statement or have it prompt me to enter a date to use in the where statement.

    Thanks!



  • 2.  RE: Can you use variables in report SQL

    Posted Nov 10, 2011 07:03 AM

    I'm not sure it's possible with the currect report GUI in Process Manager.

    However it IS possible to do this in SQL Server T-SQL. You can create a stored procedure that returns the data you wish based on variables passed. For example:

    CREATE PROCEDURE sp_blah (
    @name NVARCHAR(255)
    )
    AS
    SELECT * FROM Document WHERE Name = @name

    will create a stored procedure. You can execute it with whatever variables you like with the following:

    exec sp_blah 'woot'