How can you retrieve the report or other SQL queries from the database?
ITMS 8.x
The SQL queries from reports are stored in the State column in the Item table. These are the step to follow to retrieve the SQL queries
1.) Open Microsoft SQL Server Management Studio
2.) Change the results of a query then is run in Query Analyzer
a.) Open menu Tools > Options > Query Results > SQL Server and select the Results to Text option.
b.) Change the value Maximum number of characters displayed in each column; from 256 (default) to say 8000.
c.) Select the button OK
3.) Run the following SQL query. This will retrieve the queries from reports. This includes the all level queries (0, 1, 2 …) and parameter values/queries as well.
-- This SQL query will snap the report name and the queries section of the ntext data
select
[Report Name] = it.[name],
[Query String] = case
when (charindex('</item>', it.[state]) > 0 ) then
substring(it.[state], charindex('<queries>', it.[state]),charindex('</queries>', it.[state]))
else substring(it.[state], charindex('<queries>', it.[state]), 4000)
end
from item it join vReport vr on it.[guid] = vr.[guid]
where it.[state] is not null
and it.[Name] like '%'
and vr.[Description] like '%'
order by 1
4.) Save the SQL query results to a csv file.
Notes: