| Author |
Topic |
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2008-05-15 : 12:04:51
|
| GreetingsGot bulk insert thing going real nice thanks to your feedback! But now I notice that the BULK INSERT creates 2 identical rows while the flat file has the column headers and then corresponding row, just one row.Why would it do that. Interestingly if the data file and format file are residing on a shared folder on SQL 2005, and I ran the BULK INSERT from studio it only inserts one row. But when I do BULK INSERT via user interface it creates 2 rows. What is going here. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-15 : 12:13:30
|
| user interface? From where? What command are you using through it? |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2008-05-15 : 12:21:18
|
| I apologize if this is in the wrong post. Access Adp, resides on user machine. calls via cmd object that calls my stored procedure:dbo.usp_BulkInsert.usp_BulkInsertBULK INSERT dbo.StagingTableFROM '\\remoteserver\shareddrive\DataFile.txt'WITH (FIRSTROW = 2, FORMATFILE = '\\remoteserver\shareddrive\Format.txt') |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2008-05-15 : 12:33:48
|
| ExplainWhat 2 rows?If you're using a sproc, then you're goldenpost the sprocIf the sproc runs in ssms or QA without a problem, then it's the appIF the table (staging?) needs to be cleared out before the sproc, then are you doing that?Tell us, step by step what you are trying to accomplishBrett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxAdd yourself!http://www.frappr.com/sqlteam |
 |
|
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2008-05-15 : 12:41:28
|
| Brett, hope this is more detailed :O)Here is the content of the DataFile.txt, tab delimitedMaterial Width Length Qty Under OrderNo818164 12.65 26.5 25 23 PRL14here is the content of the format.txt8.061 SQLCHAR 0 50 "\t" 1 Material SQL_Latin1_General_CP437_BIN2 SQLCHAR 0 50 "\t" 2 Width SQL_Latin1_General_CP1_CI_AS3 SQLCHAR 0 50 "\t" 3 Length SQL_Latin1_General_CP1_CI_AS4 SQLCHAR 0 50 "\t" 4 Qty SQL_Latin1_General_CP1_CI_AS5 SQLCHAR 0 50 "\t" 5 Under SQL_Latin1_General_CP1_CI_AS6 SQLCHAR 0 50 "\r\n" 6 OrderNo SQL_Latin1_General_CP1_CI_ASStaging table is identical to datafile as far structure same fieldsas you notice I only have "one row" on the data file the first row is just header information which I bypass in my sproc by saying FIRSTROW = 2 as on of the parameters in the syntax. |
 |
|
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2008-05-15 : 12:50:35
|
| same thing happens when I change my sproc from BULK INSERT _to_ INSERT INTO syntax2 rows created when sproc called from app with datafile and format file residing on a seperate server's remote shared folder1 row created when sproc called from management studio with datafile and format file residing on shared drive on SQL Servertry it if you do not believe me , is this a SQL bug or security setting problem on our SQL server>>dbo.usp_BulkInsertINSERT INTO dbo.StagingTableSELECT DISTINCT Material, Width, Length, Qty, Under, OrderNo --SELECT *FROM OPENROWSET(BULK '\\remoteserver\shareddrive\TitanUnderReport.txt', FORMATFILE = '\\remoteserver\shareddrive\format.txt', FIRSTROW = 2) AS Q |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2008-05-15 : 12:54:13
|
| ok I will try as you say. but why would it do it differently when running it from management studio and identical format and data file reside on sql server shared folder. does it maybe have to do with ANSI mansi stuff? |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2008-05-15 : 13:08:11
|
quote: Originally posted by yosiasz ok I will try as you say. but why would it do it differently when running it from management studio and identical format and data file reside on sql server shared folder. does it maybe have to do with ANSI mansi stuff?
Don't know...if you are saying that it works via SSMS, then it's the appBrett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxAdd yourself!http://www.frappr.com/sqlteam |
 |
|
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2008-05-15 : 18:19:00
|
| ok it does seem like it is in the app. how can I trace it, is it possible to trace this problem. obviously it seems like it is running twice. but who how where when? is there a debugger or tracer in SQL 2005? |
 |
|
|
|