﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / SQL Server 2005 Strategies  / Parsing tab selimited text into SQL table / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 21 May 2013 07:44:16 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Parsing tab selimited text into SQL table</title><link>http://www.sqlservercentral.com/Forums/Topic1264566-361-1.aspx</link><description>Thanks, Orlando.</description><pubDate>Wed, 14 Mar 2012 23:20:46 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Parsing tab selimited text into SQL table</title><link>http://www.sqlservercentral.com/Forums/Topic1264566-361-1.aspx</link><description>The batch size comes into play when loading the data into the database which is downstream from the issue I am highlighting.The SqlBulkCopy.WriteToServer method (4 overloads) is how the class is told to begin loading the data to the database. The most common of the three overloads is the one that accepts an ADO.NET DataTable, the [u][url=http://msdn.microsoft.com/en-us/library/ex21zs8x.aspx]WriteToServer(DataTable) method[/url][/u], and that DataTable by definition is a memory-resident object containing the data to load, the entire file in the most generic case. That is the most common way to leverage the SqlBulkCopy class and how the overwhelming majority of the basic internet tutorials show it.The most interesting of the three overloads to me is [u][url=http://msdn.microsoft.com/en-us/library/434atets.aspx]the one that accepts an IDataReader[/url][/u]. The example on MSDN alludes to the original intent of this overload which was to enable table-to-table data copying by passing in a SQL ExecuteReader (executes a SELECT from one database to load into another), a very powerful and handy amethod indeed. With only a few lines of code we can copy all data from all tables in one database to a database with the same schema on another instance (database copy wizard anyone?). That said, I would find it much more interesting if one could easily pass an IDataReader hooked up to a flat-file reader. Then you would have something analogous to a subset of the bcp.exe functionality written in .NET, but I have not tried it nor looked to see if anyone has gone there mainly because we have SSIS, bcp.exe, BULK INSERT and many other tools already capable of doing the task and I have never been boxed into an environment where I would need such a thing.edit: excuse me, there are 4 WriteToServer overloads, not 3</description><pubDate>Wed, 14 Mar 2012 22:38:23 GMT</pubDate><dc:creator>opc.three</dc:creator></item><item><title>RE: Parsing tab selimited text into SQL table</title><link>http://www.sqlservercentral.com/Forums/Topic1264566-361-1.aspx</link><description>Ummmm... that class has a batch size parameter to it.  I'm not a C# programmer but wouldn't that prevent the whole 9 yards from being loaded at once?</description><pubDate>Wed, 14 Mar 2012 22:20:17 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Parsing tab selimited text into SQL table</title><link>http://www.sqlservercentral.com/Forums/Topic1264566-361-1.aspx</link><description>[quote][b]Lisa Cherney (3/14/2012)[/b][hr]If you need to do this from a .net application, load your data from the file into a DataTable and then use the SQLBulkCopy class (http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.aspx) to move the data to your database.[/quote]Caveat to this approach: make sure the memory on your server is ample, the generic implementation of this technique requires that the entire data file be loaded into memory before it is bulk copied to the server.</description><pubDate>Wed, 14 Mar 2012 08:58:36 GMT</pubDate><dc:creator>opc.three</dc:creator></item><item><title>RE: Parsing tab selimited text into SQL table</title><link>http://www.sqlservercentral.com/Forums/Topic1264566-361-1.aspx</link><description>If you need to do this from a .net application, load your data from the file into a DataTable and then use the SQLBulkCopy class (http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.aspx) to move the data to your database.</description><pubDate>Wed, 14 Mar 2012 06:52:28 GMT</pubDate><dc:creator>Lisa Cherney</dc:creator></item><item><title>RE: Parsing tab selimited text into SQL table</title><link>http://www.sqlservercentral.com/Forums/Topic1264566-361-1.aspx</link><description>Nary is the day when I am in an environment without an SSIS installation for use with ETL processing.</description><pubDate>Tue, 13 Mar 2012 19:49:46 GMT</pubDate><dc:creator>opc.three</dc:creator></item><item><title>RE: Parsing tab selimited text into SQL table</title><link>http://www.sqlservercentral.com/Forums/Topic1264566-361-1.aspx</link><description>[quote][b]opc.three (3/13/2012)[/b][hr][quote][b]Jeff Moden (3/13/2012)[/b][hr][quote][b]opc.three (3/13/2012)[/b][hr]If you use SQL Agent, there is no need to introduce an additional programming domain into the call stack. Ditch xp_CmdShell and call bcp from a step with type CmdExec.SSIS would be an equally capable tool to use here as well.[/quote]Ditch SSIS for an equally capable tool for this problem.  Just use BULK INSERT and be done with it. :-)[/quote]The "Fast Load Option" of the "OLE DB Destination" in SSIS implements BULK INSERT, same API.[/quote]Of course it is.  But you don't need to go anywhere near an SSIS installation with BULK INSERT.  It can all be done in T-SQL along with the rest of the processing.</description><pubDate>Tue, 13 Mar 2012 18:57:15 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Parsing tab selimited text into SQL table</title><link>http://www.sqlservercentral.com/Forums/Topic1264566-361-1.aspx</link><description>[quote][b]Jeff Moden (3/13/2012)[/b][hr][quote][b]opc.three (3/13/2012)[/b][hr]If you use SQL Agent, there is no need to introduce an additional programming domain into the call stack. Ditch xp_CmdShell and call bcp from a step with type CmdExec.SSIS would be an equally capable tool to use here as well.[/quote]Ditch SSIS for an equally capable tool for this problem.  Just use BULK INSERT and be done with it. :-)[/quote]The "Fast Load Option" of the "OLE DB Destination" in SSIS implements BULK INSERT, same API.</description><pubDate>Tue, 13 Mar 2012 17:59:00 GMT</pubDate><dc:creator>opc.three</dc:creator></item><item><title>RE: Parsing tab selimited text into SQL table</title><link>http://www.sqlservercentral.com/Forums/Topic1264566-361-1.aspx</link><description>[quote][b]opc.three (3/13/2012)[/b][hr]If you use SQL Agent, there is no need to introduce an additional programming domain into the call stack. Ditch xp_CmdShell and call bcp from a step with type CmdExec.SSIS would be an equally capable tool to use here as well.[/quote]Ditch SSIS for an equally capable tool for this problem.  Just use BULK INSERT and be done with it. :-)</description><pubDate>Tue, 13 Mar 2012 17:53:30 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Parsing tab selimited text into SQL table</title><link>http://www.sqlservercentral.com/Forums/Topic1264566-361-1.aspx</link><description>[quote][b]opc.three (3/13/2012)[/b][hr]If you use SQL Agent, there is no need to introduce an additional programming domain into the call stack. Ditch xp_CmdShell and call bcp from a step with type CmdExec.SSIS would be an equally capable tool to use here as well.[/quote]Nice, good call.</description><pubDate>Tue, 13 Mar 2012 14:15:05 GMT</pubDate><dc:creator>seth delconte</dc:creator></item><item><title>RE: Parsing tab selimited text into SQL table</title><link>http://www.sqlservercentral.com/Forums/Topic1264566-361-1.aspx</link><description>If you use SQL Agent, there is no need to introduce an additional programming domain into the call stack. Ditch xp_CmdShell and call bcp from a step with type CmdExec.SSIS would be an equally capable tool to use here as well.</description><pubDate>Tue, 13 Mar 2012 13:57:50 GMT</pubDate><dc:creator>opc.three</dc:creator></item><item><title>RE: Parsing tab selimited text into SQL table</title><link>http://www.sqlservercentral.com/Forums/Topic1264566-361-1.aspx</link><description>OR execute BCP right from a scheduled SQL Agent job.  Here's a similar script I've used for a CSV file (you can change it for tab delimited use): [code="sql"]declare @cmd varchar(1000)set @cmd = 'bcp AdventureWorks.dbo.mytest in "C:\test.csv" -t "," -r  -c -q -S MYSERVER -T'exec xp_cmdshell @cmd[/code]</description><pubDate>Fri, 09 Mar 2012 12:18:53 GMT</pubDate><dc:creator>seth delconte</dc:creator></item><item><title>RE: Parsing tab selimited text into SQL table</title><link>http://www.sqlservercentral.com/Forums/Topic1264566-361-1.aspx</link><description>How about creating a batch that executes a BCP (Bulk Copy Program) script?</description><pubDate>Fri, 09 Mar 2012 12:15:09 GMT</pubDate><dc:creator>seth delconte</dc:creator></item><item><title>Parsing tab selimited text into SQL table</title><link>http://www.sqlservercentral.com/Forums/Topic1264566-361-1.aspx</link><description>Hello! I have a weekly tab delimited file that is currently being parsed row by row in .net code and then inserted into a new table. The table created has 503 columns with varying row counts from week to week. The current process takes way to long because each row is parsed one by one.I'm looking desperately for a quicker way to accomplish this process. Ingredients:1. Tab delimited text file2. MS SQL Server database3. Program is run .NetHas anyone run across a similar situation or can anyone suggest a time efficient way to get this done?Thanks in advance for any help!</description><pubDate>Fri, 09 Mar 2012 12:11:51 GMT</pubDate><dc:creator>KirkEB</dc:creator></item></channel></rss>