﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » .NET Forums » General .NET Discussion  » Inserting records into a table....</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Wed, 10 Jun 2026 22:58:23 GMT</lastBuildDate><ttl>20</ttl><item><title>Inserting records into a table....</title><link>http://forum.strataframe.net/FindPost5816.aspx</link><description>I'm importing data from a CSV file.  I am reading the file in using TextFieldParser and while I read it in I am building an INSERT sql statement on the fly. Here is what the SQL statement looks like:&lt;br&gt;
&lt;br&gt;
INSERT INTO STITagsImport (TagNumber) &lt;br&gt;
SELECT tbl.Expr1 FROM (&lt;br&gt;
     SELECT 'ATV0E0' AS Expr1 UNION ALL&lt;br&gt;
     SELECT 'ATV0E0' AS Expr1 UNION ALL&lt;br&gt;
     SELECT '1180849' AS Expr1 UNION ALL&lt;br&gt;
     SELECT 'END' AS Expr1 &lt;br&gt;
) AS tbl&lt;br&gt;
&lt;br&gt;
The reason I am doing this is because I dont want to make four separate round trips to the database with four separate INSERT statements. I was just wondering if there was a better way.</description><pubDate>Mon, 15 Jan 2007 12:34:30 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: Inserting records into a table....</title><link>http://forum.strataframe.net/FindPost5840.aspx</link><description>It is very clever.&amp;nbsp; And bulk updates might not be for you :)</description><pubDate>Mon, 15 Jan 2007 12:34:30 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Inserting records into a table....</title><link>http://forum.strataframe.net/FindPost5834.aspx</link><description>Thanks for the suggestion Ben. I thought my way was pretty clever I just was curious if there was a better way. :)</description><pubDate>Mon, 15 Jan 2007 11:49:24 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: Inserting records into a table....</title><link>http://forum.strataframe.net/FindPost5830.aspx</link><description>Not without specifying the parameters explicitly.&amp;nbsp; And building the command dynamically.&amp;nbsp; You might also look at the SQL bulk update functionality... especially if you're updating more than just 4 rows.&amp;nbsp; System.Data.SqlClient.SqlBulkCopy is the object, I think.</description><pubDate>Mon, 15 Jan 2007 11:06:00 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item></channel></rss>