|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, March 12, 2012 6:42 AM
Points: 4,
Visits: 6
|
|
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 file 2. MS SQL Server database 3. Program is run .Net
Has anyone run across a similar situation or can anyone suggest a time efficient way to get this done? Thanks in advance for any help!
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Monday, May 13, 2013 11:44 AM
Points: 1,603,
Visits: 1,179
|
|
How about creating a batch that executes a BCP (Bulk Copy Program) script?
_________________________________ seth delconte http://sqlkeys.com
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Monday, May 13, 2013 11:44 AM
Points: 1,603,
Visits: 1,179
|
|
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):
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
_________________________________ seth delconte http://sqlkeys.com
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 11:13 AM
Points: 6,730,
Visits: 11,780
|
|
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.
__________________________________________________________________________________________________ There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Monday, May 13, 2013 11:44 AM
Points: 1,603,
Visits: 1,179
|
|
opc.three (3/13/2012) 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. Nice, good call.
_________________________________ seth delconte http://sqlkeys.com
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 8:14 AM
Points: 32,910,
Visits: 26,802
|
|
opc.three (3/13/2012) 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.
Ditch SSIS for an equally capable tool for this problem. Just use BULK INSERT and be done with it.
--Jeff Moden "RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".
First step towards the paradigm shift of writing Set Based code: Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
For better, quicker answers on T-SQL questions, click on the following... http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following... http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 11:13 AM
Points: 6,730,
Visits: 11,780
|
|
Jeff Moden (3/13/2012)
opc.three (3/13/2012) 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.Ditch SSIS for an equally capable tool for this problem. Just use BULK INSERT and be done with it.  The "Fast Load Option" of the "OLE DB Destination" in SSIS implements BULK INSERT, same API.
__________________________________________________________________________________________________ There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 8:14 AM
Points: 32,910,
Visits: 26,802
|
|
opc.three (3/13/2012)
Jeff Moden (3/13/2012)
opc.three (3/13/2012) 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.Ditch SSIS for an equally capable tool for this problem. Just use BULK INSERT and be done with it.  The "Fast Load Option" of the "OLE DB Destination" in SSIS implements BULK INSERT, same API.
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.
--Jeff Moden "RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".
First step towards the paradigm shift of writing Set Based code: Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
For better, quicker answers on T-SQL questions, click on the following... http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following... http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 11:13 AM
Points: 6,730,
Visits: 11,780
|
|
Nary is the day when I am in an environment without an SSIS installation for use with ETL processing.
__________________________________________________________________________________________________ There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Today @ 6:19 AM
Points: 9,
Visits: 1,701
|
|
| 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.
|
|
|
|