Tuesday, 4 November 2008

Use FMTONLY To Obtain an Query or stored procedure metadata

When executing a t-sql or stored procedure, if set FMTONLY value to ON, an zero-row resultset is produced with metadata information. The full query is not run. This feature is used for many report designers like Crystal Report and Reporting Service.

For example:

SET FMTONLY ON
select * from dbo.Items
SET FMTONLY OFF

The result is an empty row with column names and column data types.