<?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/"
		>
<channel>
	<title>Comments on: SQL Server 2008 Table Valued Parameters</title>
	<atom:link href="http://www.aneef.net/2007/12/23/sql-server-2008-table-valued-parameters/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.aneef.net/2007/12/23/sql-server-2008-table-valued-parameters/</link>
	<description>Do it in .Net way &#124; Blogging about C#,ASP.Net, LINQ,WPF and .Net Technologies</description>
	<lastBuildDate>Sat, 05 Nov 2011 07:42:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Adam</title>
		<link>http://www.aneef.net/2007/12/23/sql-server-2008-table-valued-parameters/comment-page-1/#comment-398</link>
		<dc:creator>Adam</dc:creator>
		<pubDate>Tue, 01 Dec 2009 20:05:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.aneef.net/2007/12/23/sql-server-2008-table-valued-parameters/#comment-398</guid>
		<description>I know this is an old comment string and an even older article, but the solution si simply to not insert into the identity column. 

INSERT INTO @InputFile(strRow) VALUES (‘A3&#124;BB&#124;C&#124;DDD’)

If this is the first record in the table it will populate with 1. If you then ran this a second time you would get a second row inserted with the same &quot;strRow&quot; value, but a 2 in the &quot;numCols&quot; column. The identity values need to be left out of the stored proc inserting into the table. If they need to be added you would have to do the part of setting identity insert off/on for the run. The tablein your code would not even need the identity column included.</description>
		<content:encoded><![CDATA[<p>I know this is an old comment string and an even older article, but the solution si simply to not insert into the identity column. </p>
<p>INSERT INTO @InputFile(strRow) VALUES (‘A3|BB|C|DDD’)</p>
<p>If this is the first record in the table it will populate with 1. If you then ran this a second time you would get a second row inserted with the same &#8220;strRow&#8221; value, but a 2 in the &#8220;numCols&#8221; column. The identity values need to be left out of the stored proc inserting into the table. If they need to be added you would have to do the part of setting identity insert off/on for the run. The tablein your code would not even need the identity column included.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam</title>
		<link>http://www.aneef.net/2007/12/23/sql-server-2008-table-valued-parameters/comment-page-1/#comment-467</link>
		<dc:creator>Adam</dc:creator>
		<pubDate>Tue, 01 Dec 2009 20:05:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.aneef.net/2007/12/23/sql-server-2008-table-valued-parameters/#comment-467</guid>
		<description>I know this is an old comment string and an even older article, but the solution si simply to not insert into the identity column. 

INSERT INTO @InputFile(strRow) VALUES (‘A3&#124;BB&#124;C&#124;DDD’)

If this is the first record in the table it will populate with 1. If you then ran this a second time you would get a second row inserted with the same &quot;strRow&quot; value, but a 2 in the &quot;numCols&quot; column. The identity values need to be left out of the stored proc inserting into the table. If they need to be added you would have to do the part of setting identity insert off/on for the run. The tablein your code would not even need the identity column included.</description>
		<content:encoded><![CDATA[<p>I know this is an old comment string and an even older article, but the solution si simply to not insert into the identity column. </p>
<p>INSERT INTO @InputFile(strRow) VALUES (‘A3|BB|C|DDD’)</p>
<p>If this is the first record in the table it will populate with 1. If you then ran this a second time you would get a second row inserted with the same &#8220;strRow&#8221; value, but a 2 in the &#8220;numCols&#8221; column. The identity values need to be left out of the stored proc inserting into the table. If they need to be added you would have to do the part of setting identity insert off/on for the run. The tablein your code would not even need the identity column included.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aneef Fashir</title>
		<link>http://www.aneef.net/2007/12/23/sql-server-2008-table-valued-parameters/comment-page-1/#comment-166</link>
		<dc:creator>Aneef Fashir</dc:creator>
		<pubDate>Tue, 16 Jun 2009 11:59:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.aneef.net/2007/12/23/sql-server-2008-table-valued-parameters/#comment-166</guid>
		<description>Ryan,

Try doing this in your SQL Statement:


&lt;blockquote&gt;SET IDENTITY_INSERT  ON

at the beginning of your SQL and

SET IDENTITY_INSERT  OFF&lt;/blockquote&gt;



because if you read the following : it seems we need to set this for each session of update when we use table valued parameters, and Identity columns. update me if it works. I haven&#039;t tested it as I&#039;M at work right now. 

http://msdn.microsoft.com/en-us/library/bb675163.aspx
Thanks</description>
		<content:encoded><![CDATA[<p>Ryan,</p>
<p>Try doing this in your SQL Statement:</p>
<blockquote><p>SET IDENTITY_INSERT  ON</p>
<p>at the beginning of your SQL and</p>
<p>SET IDENTITY_INSERT  OFF</p></blockquote>
<p>because if you read the following : it seems we need to set this for each session of update when we use table valued parameters, and Identity columns. update me if it works. I haven&#8217;t tested it as I&#8217;M at work right now. </p>
<p><a href="http://msdn.microsoft.com/en-us/library/bb675163.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/bb675163.aspx</a><br />
Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aneef Fashir</title>
		<link>http://www.aneef.net/2007/12/23/sql-server-2008-table-valued-parameters/comment-page-1/#comment-466</link>
		<dc:creator>Aneef Fashir</dc:creator>
		<pubDate>Tue, 16 Jun 2009 11:59:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.aneef.net/2007/12/23/sql-server-2008-table-valued-parameters/#comment-466</guid>
		<description>Ryan,

Try doing this in your SQL Statement:


&lt;blockquote&gt;SET IDENTITY_INSERT  ON

at the beginning of your SQL and

SET IDENTITY_INSERT  OFF&lt;/blockquote&gt;



because if you read the following : it seems we need to set this for each session of update when we use table valued parameters, and Identity columns. update me if it works. I haven&#039;t tested it as I&#039;M at work right now. 

http://msdn.microsoft.com/en-us/library/bb675163.aspx
Thanks</description>
		<content:encoded><![CDATA[<p>Ryan,</p>
<p>Try doing this in your SQL Statement:</p>
<blockquote><p>SET IDENTITY_INSERT  ON</p>
<p>at the beginning of your SQL and</p>
<p>SET IDENTITY_INSERT  OFF</p></blockquote>
<p>because if you read the following : it seems we need to set this for each session of update when we use table valued parameters, and Identity columns. update me if it works. I haven&#8217;t tested it as I&#8217;M at work right now. </p>
<p><a href="http://msdn.microsoft.com/en-us/library/bb675163.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/bb675163.aspx</a><br />
Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan Daulton</title>
		<link>http://www.aneef.net/2007/12/23/sql-server-2008-table-valued-parameters/comment-page-1/#comment-165</link>
		<dc:creator>Ryan Daulton</dc:creator>
		<pubDate>Tue, 16 Jun 2009 10:43:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.aneef.net/2007/12/23/sql-server-2008-table-valued-parameters/#comment-165</guid>
		<description>Thanks Aneef,

But is there any way to have identity column autoincrement without me changing IDENTITY_INSERT?  Otherwise, how do i get the IDENTITY_INSERT value to remain on? 
I tried setting the IDENTITY_INSERT to ON from SQL Management Studio:
&quot;
SET IDENTITY_INSERT ParentTable ON
GO
DECLARE @InputFile parseInputFile
INSERT INTO @InputFile(NumCols, strRow) VALUES (1, &#039;A3&#124;BB&#124;C&#124;DDD&#039;)
select * from @InputFile
&quot;
But then compiler returned following error:

&quot;
Msg 1077, Level 16, State 1, Line 2
INSERT into an identity column not allowed on table variables.
&quot;

And this is using same table UDT, parseInputFile, which is defined as:
&quot;
CREATE TYPE [dbo].[parseInputFile] AS TABLE(
	[NumCols] [int] IDENTITY(1,1) NOT NULL,
	[strRow] [varchar](500) NOT NULL,
	PRIMARY KEY CLUSTERED 
&quot;

Since I&#039;m getting this error in Management Studio, I know it won&#039;t work in VS 2008 either.  However, I did try this in VS 2008 and I am still getting same exception.  So what exactly should I change?</description>
		<content:encoded><![CDATA[<p>Thanks Aneef,</p>
<p>But is there any way to have identity column autoincrement without me changing IDENTITY_INSERT?  Otherwise, how do i get the IDENTITY_INSERT value to remain on?<br />
I tried setting the IDENTITY_INSERT to ON from SQL Management Studio:<br />
&#8221;<br />
SET IDENTITY_INSERT ParentTable ON<br />
GO<br />
DECLARE @InputFile parseInputFile<br />
INSERT INTO @InputFile(NumCols, strRow) VALUES (1, &#8216;A3|BB|C|DDD&#8217;)<br />
select * from @InputFile<br />
&#8221;<br />
But then compiler returned following error:</p>
<p>&#8221;<br />
Msg 1077, Level 16, State 1, Line 2<br />
INSERT into an identity column not allowed on table variables.<br />
&#8221;</p>
<p>And this is using same table UDT, parseInputFile, which is defined as:<br />
&#8221;<br />
CREATE TYPE [dbo].[parseInputFile] AS TABLE(<br />
	[NumCols] [int] IDENTITY(1,1) NOT NULL,<br />
	[strRow] [varchar](500) NOT NULL,<br />
	PRIMARY KEY CLUSTERED<br />
&#8221;</p>
<p>Since I&#8217;m getting this error in Management Studio, I know it won&#8217;t work in VS 2008 either.  However, I did try this in VS 2008 and I am still getting same exception.  So what exactly should I change?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan Daulton</title>
		<link>http://www.aneef.net/2007/12/23/sql-server-2008-table-valued-parameters/comment-page-1/#comment-465</link>
		<dc:creator>Ryan Daulton</dc:creator>
		<pubDate>Tue, 16 Jun 2009 10:43:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.aneef.net/2007/12/23/sql-server-2008-table-valued-parameters/#comment-465</guid>
		<description>Thanks Aneef,

But is there any way to have identity column autoincrement without me changing IDENTITY_INSERT?  Otherwise, how do i get the IDENTITY_INSERT value to remain on? 
I tried setting the IDENTITY_INSERT to ON from SQL Management Studio:
&quot;
SET IDENTITY_INSERT ParentTable ON
GO
DECLARE @InputFile parseInputFile
INSERT INTO @InputFile(NumCols, strRow) VALUES (1, &#039;A3&#124;BB&#124;C&#124;DDD&#039;)
select * from @InputFile
&quot;
But then compiler returned following error:

&quot;
Msg 1077, Level 16, State 1, Line 2
INSERT into an identity column not allowed on table variables.
&quot;

And this is using same table UDT, parseInputFile, which is defined as:
&quot;
CREATE TYPE [dbo].[parseInputFile] AS TABLE(
	[NumCols] [int] IDENTITY(1,1) NOT NULL,
	[strRow] [varchar](500) NOT NULL,
	PRIMARY KEY CLUSTERED 
&quot;

Since I&#039;m getting this error in Management Studio, I know it won&#039;t work in VS 2008 either.  However, I did try this in VS 2008 and I am still getting same exception.  So what exactly should I change?</description>
		<content:encoded><![CDATA[<p>Thanks Aneef,</p>
<p>But is there any way to have identity column autoincrement without me changing IDENTITY_INSERT?  Otherwise, how do i get the IDENTITY_INSERT value to remain on?<br />
I tried setting the IDENTITY_INSERT to ON from SQL Management Studio:<br />
&#8221;<br />
SET IDENTITY_INSERT ParentTable ON<br />
GO<br />
DECLARE @InputFile parseInputFile<br />
INSERT INTO @InputFile(NumCols, strRow) VALUES (1, &#8216;A3|BB|C|DDD&#8217;)<br />
select * from @InputFile<br />
&#8221;<br />
But then compiler returned following error:</p>
<p>&#8221;<br />
Msg 1077, Level 16, State 1, Line 2<br />
INSERT into an identity column not allowed on table variables.<br />
&#8221;</p>
<p>And this is using same table UDT, parseInputFile, which is defined as:<br />
&#8221;<br />
CREATE TYPE [dbo].[parseInputFile] AS TABLE(<br />
	[NumCols] [int] IDENTITY(1,1) NOT NULL,<br />
	[strRow] [varchar](500) NOT NULL,<br />
	PRIMARY KEY CLUSTERED<br />
&#8221;</p>
<p>Since I&#8217;m getting this error in Management Studio, I know it won&#8217;t work in VS 2008 either.  However, I did try this in VS 2008 and I am still getting same exception.  So what exactly should I change?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aneef Fashir</title>
		<link>http://www.aneef.net/2007/12/23/sql-server-2008-table-valued-parameters/comment-page-1/#comment-164</link>
		<dc:creator>Aneef Fashir</dc:creator>
		<pubDate>Tue, 16 Jun 2009 05:11:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.aneef.net/2007/12/23/sql-server-2008-table-valued-parameters/#comment-164</guid>
		<description>&lt;blockquote&gt;Hi Ryan,

If you supply a value for an identity column in a table-valued parameter, you must issue the SET IDENTITY_INSERT statement for the session.

Hope it Helps&lt;/blockquote&gt;</description>
		<content:encoded><![CDATA[<blockquote><p>Hi Ryan,</p>
<p>If you supply a value for an identity column in a table-valued parameter, you must issue the SET IDENTITY_INSERT statement for the session.</p>
<p>Hope it Helps</p></blockquote>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aneef Fashir</title>
		<link>http://www.aneef.net/2007/12/23/sql-server-2008-table-valued-parameters/comment-page-1/#comment-464</link>
		<dc:creator>Aneef Fashir</dc:creator>
		<pubDate>Tue, 16 Jun 2009 05:11:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.aneef.net/2007/12/23/sql-server-2008-table-valued-parameters/#comment-464</guid>
		<description>&lt;blockquote&gt;Hi Ryan,

If you supply a value for an identity column in a table-valued parameter, you must issue the SET IDENTITY_INSERT statement for the session.

Hope it Helps&lt;/blockquote&gt;</description>
		<content:encoded><![CDATA[<blockquote><p>Hi Ryan,</p>
<p>If you supply a value for an identity column in a table-valued parameter, you must issue the SET IDENTITY_INSERT statement for the session.</p>
<p>Hope it Helps</p></blockquote>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan Daulton</title>
		<link>http://www.aneef.net/2007/12/23/sql-server-2008-table-valued-parameters/comment-page-1/#comment-163</link>
		<dc:creator>Ryan Daulton</dc:creator>
		<pubDate>Tue, 16 Jun 2009 02:09:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.aneef.net/2007/12/23/sql-server-2008-table-valued-parameters/#comment-163</guid>
		<description>Hi Aneef,

I like your example very much!  I&#039;ve been looking for a Table UDT example for a long time.  I tried your solution, however, the difference with my code is that my table type has the first column as an Identity column.  
So when I try to execute the InsertFileDetails SP, C# VS 2008 debug says &quot;Insert into IDENTITY column isn&#039;t allowed on table variables.&quot;  How do I fix this?  Here is a snippet of my code:
&quot;
 DataTable dt = new DataTable();
            String[] header = myStringArray[0].Split(&#039;&#124;&#039;);

            DataRow dr = dt.NewRow();
            DataColumn dc = new DataColumn();
            dc.DataType = typeof(Int32);
            dc.ColumnName = &quot;NumCols&quot;;
            
            dt.Columns.Add(dc);
            DataColumn dc2 = new DataColumn();
            dc2.DataType = typeof(string);
            dc2.ColumnName = &quot;strRow&quot;;
            
            dt.Columns.Add(dc2);
            dt.Rows.Add(myStringArray[1]);
&quot;

But the exception doesn&#039;t get caught until I exec the ExecuteNonQuery function.

Thanks!</description>
		<content:encoded><![CDATA[<p>Hi Aneef,</p>
<p>I like your example very much!  I&#8217;ve been looking for a Table UDT example for a long time.  I tried your solution, however, the difference with my code is that my table type has the first column as an Identity column.<br />
So when I try to execute the InsertFileDetails SP, C# VS 2008 debug says &#8220;Insert into IDENTITY column isn&#8217;t allowed on table variables.&#8221;  How do I fix this?  Here is a snippet of my code:<br />
&#8221;<br />
 DataTable dt = new DataTable();<br />
            String[] header = myStringArray[0].Split(&#8216;|&#8217;);</p>
<p>            DataRow dr = dt.NewRow();<br />
            DataColumn dc = new DataColumn();<br />
            dc.DataType = typeof(Int32);<br />
            dc.ColumnName = &#8220;NumCols&#8221;;</p>
<p>            dt.Columns.Add(dc);<br />
            DataColumn dc2 = new DataColumn();<br />
            dc2.DataType = typeof(string);<br />
            dc2.ColumnName = &#8220;strRow&#8221;;</p>
<p>            dt.Columns.Add(dc2);<br />
            dt.Rows.Add(myStringArray[1]);<br />
&#8221;</p>
<p>But the exception doesn&#8217;t get caught until I exec the ExecuteNonQuery function.</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan Daulton</title>
		<link>http://www.aneef.net/2007/12/23/sql-server-2008-table-valued-parameters/comment-page-1/#comment-463</link>
		<dc:creator>Ryan Daulton</dc:creator>
		<pubDate>Tue, 16 Jun 2009 02:09:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.aneef.net/2007/12/23/sql-server-2008-table-valued-parameters/#comment-463</guid>
		<description>Hi Aneef,

I like your example very much!  I&#039;ve been looking for a Table UDT example for a long time.  I tried your solution, however, the difference with my code is that my table type has the first column as an Identity column.  
So when I try to execute the InsertFileDetails SP, C# VS 2008 debug says &quot;Insert into IDENTITY column isn&#039;t allowed on table variables.&quot;  How do I fix this?  Here is a snippet of my code:
&quot;
 DataTable dt = new DataTable();
            String[] header = myStringArray[0].Split(&#039;&#124;&#039;);

            DataRow dr = dt.NewRow();
            DataColumn dc = new DataColumn();
            dc.DataType = typeof(Int32);
            dc.ColumnName = &quot;NumCols&quot;;
            
            dt.Columns.Add(dc);
            DataColumn dc2 = new DataColumn();
            dc2.DataType = typeof(string);
            dc2.ColumnName = &quot;strRow&quot;;
            
            dt.Columns.Add(dc2);
            dt.Rows.Add(myStringArray[1]);
&quot;

But the exception doesn&#039;t get caught until I exec the ExecuteNonQuery function.

Thanks!</description>
		<content:encoded><![CDATA[<p>Hi Aneef,</p>
<p>I like your example very much!  I&#8217;ve been looking for a Table UDT example for a long time.  I tried your solution, however, the difference with my code is that my table type has the first column as an Identity column.<br />
So when I try to execute the InsertFileDetails SP, C# VS 2008 debug says &#8220;Insert into IDENTITY column isn&#8217;t allowed on table variables.&#8221;  How do I fix this?  Here is a snippet of my code:<br />
&#8221;<br />
 DataTable dt = new DataTable();<br />
            String[] header = myStringArray[0].Split(&#8216;|&#8217;);</p>
<p>            DataRow dr = dt.NewRow();<br />
            DataColumn dc = new DataColumn();<br />
            dc.DataType = typeof(Int32);<br />
            dc.ColumnName = &#8220;NumCols&#8221;;</p>
<p>            dt.Columns.Add(dc);<br />
            DataColumn dc2 = new DataColumn();<br />
            dc2.DataType = typeof(string);<br />
            dc2.ColumnName = &#8220;strRow&#8221;;</p>
<p>            dt.Columns.Add(dc2);<br />
            dt.Rows.Add(myStringArray[1]);<br />
&#8221;</p>
<p>But the exception doesn&#8217;t get caught until I exec the ExecuteNonQuery function.</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Served from: www.aneef.net @ 2012-02-04 23:45:11 by W3 Total Cache -->
