473,549 Members | 2,543 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Bulk Import with header in text file

I would appreciate some help on a procedure that I have. Using Bulk
Insert, I would like to import records from a text file. The issue I
have is the file contains a header - '1AMC_TO_Axiz' and a footer
'1AMC_TO_Axiz2" . Using a format file, I can get the import to work by
editing the file and removing these two entries. Is there a way to
setup the format file to skip these two entries? My file currently
looks like this:
7.0
16
1 SQLCHAR 0 50 "|" 1 keyMemberNo
2 SQLCHAR 0 10 "|" 2 fldEffdate
............... ..
16 SQLCHAR 0 10 "\r\n" 16 fldNewRecord

Thanks
Charles

Nov 28 '05 #1
3 2628
you should be able to write a batch file to open the text file and
replace those words w/ a NULL string.

Nov 28 '05 #2
(cb****@bjtsupp ort.com) writes:
I would appreciate some help on a procedure that I have. Using Bulk
Insert, I would like to import records from a text file. The issue I
have is the file contains a header - '1AMC_TO_Axiz' and a footer
'1AMC_TO_Axiz2" . Using a format file, I can get the import to work by
editing the file and removing these two entries. Is there a way to
setup the format file to skip these two entries? My file currently
looks like this:
7.0
16
1 SQLCHAR 0 50 "|" 1 keyMemberNo
2 SQLCHAR 0 10 "|" 2 fldEffdate
............... .
16 SQLCHAR 0 10 "\r\n" 16 fldNewRecord


BCP is very squared, and there is no way to specify a footer or a header.
The one exception is when you can hide the header in the format somehow.
If the headers fits into the format, you can the FIRSTROW and LASTROW
options to skip them.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Nov 28 '05 #3
Thanks for the replies! At least I now know that I did not miss
something!

Nov 30 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
4845
by: atse | last post by:
Hi, I am still stick on the text file being imported to database. Can anybody help? I have just done the csv format files. And then I work on text and DAT formats, but I have problem to import these kinds of formats to MySQL ( and MS SQL) Please see the attachments, and the text format is changed from DAT format, delimited by tabs or...
0
2147
by: adrian GREEMAN | last post by:
When I try to import a text file with new data for an existing table I get the error "1148 - the used command is not allowed with this MySQL version." I have tried with both PHPMyAdmin2.3 and with MySQLFront 2.5. Both these GUI programmes have an "import from text file" command which I have used successfully several times to add entries to...
3
2871
by: Frank Reichenbacher | last post by:
I've been developing an Access database for our small office for several years now so I am not a newbie. However, I have a need for which I am not finding a mechanism to accomplish in the material that I have read. We use an antique BBX/BASIC accounting program which we use to generate invoices. Every morning we save the previous day's...
6
2879
by: MLH | last post by:
I was able to do this from Access 2.0. It had to be set up, of course, but it could be done. I'm unsure as to why Access 97 says "Can't find file"??? C:\DOCUME~1\Owner\LOCALS~1\Temp\WER2E70.tmp.dir00\appcompat.txt Notepad certainly has no problem finding and opening the file. Are any of you familiar with this?
0
1257
by: TJS | last post by:
I need to import a delimited text file to an msde table, I found discussion item below. anything available for msde which is comparable to this Jet example? ================================= The TEXT ODBC driver calls the Jet database engine and reads text files via Jet's Text IISAM driver. You may try code similar to the following: Dim...
0
2781
by: Shawn Ferguson | last post by:
With the help of you, I've been able to successfully load my database with the contents of a "comma" delimited file. It loads about 5000 records in about 3 seconds:) Now I have another problem. The file I will be importing into SQL Server is serparated by "|" vertical bar opposed to "," comma. When I run my program with the comma separated...
14
11163
by: mfrsousa | last post by:
hi there, i have a huge large text file (350.000 lines) that i want to import to a MS Acccess Database, of course i don't want to use Access, but do it with C#. i already have tried the AddRow method or Insert, reading each line of the text file, the problem of course is velocity, it would take more than 4 hours to add all lines/records...
8
2996
by: diasdaman | last post by:
I know how to import text files, but in this case I need to import a text file line by line on an on-the-fly basis, such that the Access will look at the first two digits of a line, and then import the rest of the line based on a given specification into an appropriate table. I'm not that familiar with VBA, but I can pick it up if I need to....
6
5100
by: serdar | last post by:
Hi, I'm developing a flash game and need to read data from a text file (about 100k). I do not want to read it from an external file. -Is it possible to somehow import a text file into flash and compile swf without a need for an external file to read at runtime? -How about putting the huge data into a string object defined in an .as file?...
12
3137
by: Miguel Valenzue | last post by:
I collect traffic data from a machine that outputs text files with the data. I want to import each text file as it's own table into an Access database and do it without having to run the import wizard for each one. As part of this function, I'd like to strip the first 15 lines of data from the dataset, parse in the first 5 columns, and name...
0
7532
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7461
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7730
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7971
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7823
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5101
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3509
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3491
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
776
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.