This example is based on and tested with QualityCenter_Demo_db database running on SQL Server 2005.
This is an example of a SQL Statement that creates a SQL Statement.
In this example:
The user seeks all the defects where the User Defined Field with the Label ''Category'' and the Category Value = ''UI Suggestion''
In the Quality Center Demo project BG_USER_05 is the field with the label ''Category''
First Run the query
select 'select * FROM td.BUG WHERE ' + A.SF_COLUMN_NAME + ' = ' + '''UI Suggestion''' as RESULT
from
(SELECT SF.SF_COLUMN_NAME, SF.SF_USER_LABEL
FROM td.SYSTEM_FIELD SF
WHERE
SF.SF_TABLE_NAME = 'BUG'
AND SF.SF_USER_LABEL = 'Category') A
The result will be:
select * FROM td.BUG WHERE BG_USER_05 = 'UI Suggestion'
Copy and run the resulting query to get the defects with a category of ''UI Suggestion''