<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; Getting Columns Headers without Result Data &#8211; SET FMTONLY ON</title>
	<atom:link href="http://blog.sqlauthority.com/2011/05/26/sql-server-getting-columns-headers-without-result-data-set-fmtonly-on/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2011/05/26/sql-server-getting-columns-headers-without-result-data-set-fmtonly-on/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Fri, 17 May 2013 15:26:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Janet Steen</title>
		<link>http://blog.sqlauthority.com/2011/05/26/sql-server-getting-columns-headers-without-result-data-set-fmtonly-on/#comment-366616</link>
		<dc:creator><![CDATA[Janet Steen]]></dc:creator>
		<pubDate>Tue, 30 Oct 2012 20:39:51 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13000#comment-366616</guid>
		<description><![CDATA[Paul - Thank you very much for sharing this post.  Been struggling with Entity Framework in VS because of this.]]></description>
		<content:encoded><![CDATA[<p>Paul &#8211; Thank you very much for sharing this post.  Been struggling with Entity Framework in VS because of this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick</title>
		<link>http://blog.sqlauthority.com/2011/05/26/sql-server-getting-columns-headers-without-result-data-set-fmtonly-on/#comment-354719</link>
		<dc:creator><![CDATA[Nick]]></dc:creator>
		<pubDate>Mon, 01 Oct 2012 00:38:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13000#comment-354719</guid>
		<description><![CDATA[To expand a bit on what Paul said,

If you&#039;re using an ORM mapper (we use ADO.NET entity framework) sometimes it will not be able to see the result set properly when you&#039;re trying to setup your mappings.  If you watch it in profiler, the framework will open a connection to the DB, SETS FMTONLY ON, then runs the proc with all NULL values passed in for the parameters.    

It works most of the time, but I occasionally Entity Framework will just report an empty result set.  I haven&#039;t seen any pattern to my SQL code when this happens, but the only fix I&#039;ve come across so far is to add  SET FMTONLY OFF within the procedure&#039;s definition and redeploy the SQL code.]]></description>
		<content:encoded><![CDATA[<p>To expand a bit on what Paul said,</p>
<p>If you&#8217;re using an ORM mapper (we use ADO.NET entity framework) sometimes it will not be able to see the result set properly when you&#8217;re trying to setup your mappings.  If you watch it in profiler, the framework will open a connection to the DB, SETS FMTONLY ON, then runs the proc with all NULL values passed in for the parameters.    </p>
<p>It works most of the time, but I occasionally Entity Framework will just report an empty result set.  I haven&#8217;t seen any pattern to my SQL code when this happens, but the only fix I&#8217;ve come across so far is to add  SET FMTONLY OFF within the procedure&#8217;s definition and redeploy the SQL code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER &#8211; Copy Column Headers from Resultset &#8211; SQL in Sixty Seconds #026 &#8211; Video &#171; SQL Server Journey with SQL Authority</title>
		<link>http://blog.sqlauthority.com/2011/05/26/sql-server-getting-columns-headers-without-result-data-set-fmtonly-on/#comment-353135</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Copy Column Headers from Resultset &#8211; SQL in Sixty Seconds #026 &#8211; Video &#171; SQL Server Journey with SQL Authority]]></dc:creator>
		<pubDate>Wed, 26 Sep 2012 01:31:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13000#comment-353135</guid>
		<description><![CDATA[[...] Getting Columns Headers without Result Data – SET FMTONLY ON [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Getting Columns Headers without Result Data – SET FMTONLY ON [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: manojb</title>
		<link>http://blog.sqlauthority.com/2011/05/26/sql-server-getting-columns-headers-without-result-data-set-fmtonly-on/#comment-349737</link>
		<dc:creator><![CDATA[manojb]]></dc:creator>
		<pubDate>Mon, 17 Sep 2012 04:23:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13000#comment-349737</guid>
		<description><![CDATA[Hi pinal , Inside set FMT ony on does not allow Go Statement .What i do 
For ex:
Set Fmt only on 

Select * from Tables1

Go

Update table1 set id =@id where name =@name 

Go 

I got Error  .what i do]]></description>
		<content:encoded><![CDATA[<p>Hi pinal , Inside set FMT ony on does not allow Go Statement .What i do<br />
For ex:<br />
Set Fmt only on </p>
<p>Select * from Tables1</p>
<p>Go</p>
<p>Update table1 set id =@id where name =@name </p>
<p>Go </p>
<p>I got Error  .what i do</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Patrick</title>
		<link>http://blog.sqlauthority.com/2011/05/26/sql-server-getting-columns-headers-without-result-data-set-fmtonly-on/#comment-311560</link>
		<dc:creator><![CDATA[Patrick]]></dc:creator>
		<pubDate>Mon, 09 Jul 2012 22:04:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13000#comment-311560</guid>
		<description><![CDATA[Select into a temp table, say #mytemp, and do this:

SELECT COLUMN_NAME FROM tempdb.INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME LIKE &#039;#mytemp%&#039;

And you will get a vertical list of the column names. You can add metadata or whatever else from INFORMATION_SCHEMA as well, of course.]]></description>
		<content:encoded><![CDATA[<p>Select into a temp table, say #mytemp, and do this:</p>
<p>SELECT COLUMN_NAME FROM tempdb.INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME LIKE &#8216;#mytemp%&#8217;</p>
<p>And you will get a vertical list of the column names. You can add metadata or whatever else from INFORMATION_SCHEMA as well, of course.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aafreen Sheikh</title>
		<link>http://blog.sqlauthority.com/2011/05/26/sql-server-getting-columns-headers-without-result-data-set-fmtonly-on/#comment-265594</link>
		<dc:creator><![CDATA[Aafreen Sheikh]]></dc:creator>
		<pubDate>Wed, 21 Mar 2012 09:03:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13000#comment-265594</guid>
		<description><![CDATA[Hi Pinal, is there a way I could get a &quot;vertical&quot; list of columns..I am interested in just the number of columns being returned..It&#039;s like saying &quot;Is there an equivalent of count(*) to count the number of columns returned by a stored procedure&quot;?]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal, is there a way I could get a &#8220;vertical&#8221; list of columns..I am interested in just the number of columns being returned..It&#8217;s like saying &#8220;Is there an equivalent of count(*) to count the number of columns returned by a stored procedure&#8221;?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Russo</title>
		<link>http://blog.sqlauthority.com/2011/05/26/sql-server-getting-columns-headers-without-result-data-set-fmtonly-on/#comment-231222</link>
		<dc:creator><![CDATA[Paul Russo]]></dc:creator>
		<pubDate>Wed, 04 Jan 2012 11:58:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13000#comment-231222</guid>
		<description><![CDATA[Hi Pinal - I found it very useful to get the ADO.NET DataSet Schema fill to work - and the LINQ2SQL designer to work - where I have used a temporary table in a stored procedure.  In this case you may get an error message saying the temporary table could not be found - after some digging around I came across the FMTONLY option and hence your post.

I found that if I set the set fmtonly off; just before I created a temporary table and set fmtonly on; just after I created the table then the schema could be read quite happily (I had joined on the temporary table for the final SELECT) - with both ADO.NET DataSets and the LINQ2SQL designer.  Apparently the ADO.NET and LINQ tools uses the FMTONLY option internally against the entire stored procedure - my fix just overrode it enough to allow temp table to be parsed as well.]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal &#8211; I found it very useful to get the ADO.NET DataSet Schema fill to work &#8211; and the LINQ2SQL designer to work &#8211; where I have used a temporary table in a stored procedure.  In this case you may get an error message saying the temporary table could not be found &#8211; after some digging around I came across the FMTONLY option and hence your post.</p>
<p>I found that if I set the set fmtonly off; just before I created a temporary table and set fmtonly on; just after I created the table then the schema could be read quite happily (I had joined on the temporary table for the final SELECT) &#8211; with both ADO.NET DataSets and the LINQ2SQL designer.  Apparently the ADO.NET and LINQ tools uses the FMTONLY option internally against the entire stored procedure &#8211; my fix just overrode it enough to allow temp table to be parsed as well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2011/05/26/sql-server-getting-columns-headers-without-result-data-set-fmtonly-on/#comment-138369</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Thu, 02 Jun 2011 09:33:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13000#comment-138369</guid>
		<description><![CDATA[Yes thats the simple solution without worrying much on SET OPTIONS]]></description>
		<content:encoded><![CDATA[<p>Yes thats the simple solution without worrying much on SET OPTIONS</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2011/05/26/sql-server-getting-columns-headers-without-result-data-set-fmtonly-on/#comment-138367</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Thu, 02 Jun 2011 09:27:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13000#comment-138367</guid>
		<description><![CDATA[If you want to know the column names quickly it is helpful]]></description>
		<content:encoded><![CDATA[<p>If you want to know the column names quickly it is helpful</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ashish Kadam</title>
		<link>http://blog.sqlauthority.com/2011/05/26/sql-server-getting-columns-headers-without-result-data-set-fmtonly-on/#comment-138316</link>
		<dc:creator><![CDATA[Ashish Kadam]]></dc:creator>
		<pubDate>Thu, 02 Jun 2011 05:52:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13000#comment-138316</guid>
		<description><![CDATA[Hi Pinal, I Am Not Understanding That What&#039;s Use Of It In Practical Scenario. In Which Situation It&#039;s Helpful to The Developer also?]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal, I Am Not Understanding That What&#8217;s Use Of It In Practical Scenario. In Which Situation It&#8217;s Helpful to The Developer also?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jay</title>
		<link>http://blog.sqlauthority.com/2011/05/26/sql-server-getting-columns-headers-without-result-data-set-fmtonly-on/#comment-138265</link>
		<dc:creator><![CDATA[Jay]]></dc:creator>
		<pubDate>Wed, 01 Jun 2011 21:28:13 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13000#comment-138265</guid>
		<description><![CDATA[Hi Pinal Also what do you think about this to get column names?
SELECT * FROM Table WHERE 1=0

I don&#039;t have to mess with the SET OPTIONS and the execution plan is doing/does a constant scan ( I also tested it on a 10 TB table)]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal Also what do you think about this to get column names?<br />
SELECT * FROM Table WHERE 1=0</p>
<p>I don&#8217;t have to mess with the SET OPTIONS and the execution plan is doing/does a constant scan ( I also tested it on a 10 TB table)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DiGi</title>
		<link>http://blog.sqlauthority.com/2011/05/26/sql-server-getting-columns-headers-without-result-data-set-fmtonly-on/#comment-136759</link>
		<dc:creator><![CDATA[DiGi]]></dc:creator>
		<pubDate>Thu, 26 May 2011 08:02:47 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13000#comment-136759</guid>
		<description><![CDATA[This is most stupid feature ever. ADO components sometimes add SET FMTONLY ON and make dry run.

But FMTONLY ignore logical statements, so this is VALID part of code:

CREATE PROCEDURE dbo.RunSomeCode(@Param VARCHAR(10))
AS

IF 1=2 -- YEAH we are in FMTONLY
BEGIN
  SET FMTONLY OFF
  -- OR EXIT procedure
END
..
..


otherwise:

1)

SELECT
  a, b
INTO
  #TABLE
FROM
  SomeTable

SELECT * FROM #Table -&gt; FAIL, because #Table will not be created



2)

-- @Foo = &#039;&#039;
SET @mark = CHARINDEX(&#039;X&#039;, @Foo)
IF @mark &gt; 0 -- WITH FMTONLY this will pass
BEGIN
  SET @SubStr = SUBSTRING(.. ) -- Error here
END]]></description>
		<content:encoded><![CDATA[<p>This is most stupid feature ever. ADO components sometimes add SET FMTONLY ON and make dry run.</p>
<p>But FMTONLY ignore logical statements, so this is VALID part of code:</p>
<p>CREATE PROCEDURE dbo.RunSomeCode(@Param VARCHAR(10))<br />
AS</p>
<p>IF 1=2 &#8212; YEAH we are in FMTONLY<br />
BEGIN<br />
  SET FMTONLY OFF<br />
  &#8212; OR EXIT procedure<br />
END<br />
..<br />
..</p>
<p>otherwise:</p>
<p>1)</p>
<p>SELECT<br />
  a, b<br />
INTO<br />
  #TABLE<br />
FROM<br />
  SomeTable</p>
<p>SELECT * FROM #Table -&gt; FAIL, because #Table will not be created</p>
<p>2)</p>
<p>&#8211; @Foo = &#8221;<br />
SET @mark = CHARINDEX(&#8216;X&#8217;, @Foo)<br />
IF @mark &gt; 0 &#8212; WITH FMTONLY this will pass<br />
BEGIN<br />
  SET @SubStr = SUBSTRING(.. ) &#8212; Error here<br />
END</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Diyan</title>
		<link>http://blog.sqlauthority.com/2011/05/26/sql-server-getting-columns-headers-without-result-data-set-fmtonly-on/#comment-136746</link>
		<dc:creator><![CDATA[Diyan]]></dc:creator>
		<pubDate>Thu, 26 May 2011 06:29:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13000#comment-136746</guid>
		<description><![CDATA[Is there any difference if I use WHERE 1=2 ?]]></description>
		<content:encoded><![CDATA[<p>Is there any difference if I use WHERE 1=2 ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Farhad Farahmandkhah</title>
		<link>http://blog.sqlauthority.com/2011/05/26/sql-server-getting-columns-headers-without-result-data-set-fmtonly-on/#comment-136744</link>
		<dc:creator><![CDATA[Farhad Farahmandkhah]]></dc:creator>
		<pubDate>Thu, 26 May 2011 06:11:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13000#comment-136744</guid>
		<description><![CDATA[Thanks]]></description>
		<content:encoded><![CDATA[<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Feodor</title>
		<link>http://blog.sqlauthority.com/2011/05/26/sql-server-getting-columns-headers-without-result-data-set-fmtonly-on/#comment-136742</link>
		<dc:creator><![CDATA[Feodor]]></dc:creator>
		<pubDate>Thu, 26 May 2011 06:02:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13000#comment-136742</guid>
		<description><![CDATA[One time, at a client, I noticed that many events in the profiler were showing with suspiciously high amount of reads. 
I looked into that, and noticed that the bactches were preceded with FMTONLY statements, and in profiler both events had as much reads. 
At the time I was surprised, since the FMTONLY ON should have a few reads, since it just returns the metadata, not the entire resultset. 
Could you please explain what the processing routine of a FMTONLY statement looks like - i.e. is the statement parsed, algebrized, optimized and so on? 

Thank you.]]></description>
		<content:encoded><![CDATA[<p>One time, at a client, I noticed that many events in the profiler were showing with suspiciously high amount of reads.<br />
I looked into that, and noticed that the bactches were preceded with FMTONLY statements, and in profiler both events had as much reads.<br />
At the time I was surprised, since the FMTONLY ON should have a few reads, since it just returns the metadata, not the entire resultset.<br />
Could you please explain what the processing routine of a FMTONLY statement looks like &#8211; i.e. is the statement parsed, algebrized, optimized and so on? </p>
<p>Thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Prasoon Pathak</title>
		<link>http://blog.sqlauthority.com/2011/05/26/sql-server-getting-columns-headers-without-result-data-set-fmtonly-on/#comment-136720</link>
		<dc:creator><![CDATA[Prasoon Pathak]]></dc:creator>
		<pubDate>Thu, 26 May 2011 03:47:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=13000#comment-136720</guid>
		<description><![CDATA[Hi Pinal, 

is it helpfull in select * into statements 
or
creating the schema of empty datatable in dot net...]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal, </p>
<p>is it helpfull in select * into statements<br />
or<br />
creating the schema of empty datatable in dot net&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
