INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Bulk Insert Multiple Text Files - blank space delimiter and tab-delimited - Error Received

Bulk Insert Multiple Text Files - blank space delimiter and tab-delimited - Error Received

Bulk Insert Multiple Text Files - blank space delimiter and tab-delimited - Error Received

(OP)
Bulk inserting multiple text files to create Lookup tables in a database using Sql Server 2012 Developer.

Able to successfully load one set of lookup tables, the ones with a blank space delimiter.

However, I encounter an error when I attempt to load the second set of text files that contain a tab delimited delimiter.

Specifically, it appears that the red error lines appear underneath the line "FIELDTERMINATOR = ' \t'"

with the error message "Incorrect syntax."


Is it recommended or even good practice to use bulk import to load multiple text files with different field delimiters using the same sql script?

Any insight as to how the example sql script below should be formatted so that the error is eliminated?


CODE

CREATE TABLE LU_Equipment(Data VARCHAR (50),MoreData varchar(50))
BULK INSERT LU_Equipment FROM 'c:\Equipment.txt'
           WITH ( 
               FIELDTERMINATOR = "   ", 
               ROWTERMINATOR = '\n', 
               FIRSTROW = 2 
            ) 


CREATE TABLE LU_Supplies(Data VARCHAR (50),MoreData varchar(50))
BULK INSERT BULKACT FROM 'c:\Supplies.txt'
           WITH ( 
               FIELDTERMINATOR = ' \t', 
               ROWTERMINATOR = '\n', 
               FIRSTROW = 2 
            ) 

RE: Bulk Insert Multiple Text Files - blank space delimiter and tab-delimited - Error Received

Hi, not sure about the error where you are saying it's occurring, however you have double quotes on the FIELDTERMINATOR = " ", which would cause an issue.

G

There are two ways to write error-free programs; only the third one works.

RE: Bulk Insert Multiple Text Files - blank space delimiter and tab-delimited - Error Received

GHolden, I think you've caught at least ONE of the OP's issues, if not THE issue. I should've seen it when I first glanced. I've been watching just b/c was interested in the general concept.

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57

RE: Bulk Insert Multiple Text Files - blank space delimiter and tab-delimited - Error Received

kjv1611, thanks, not addressing the question as such, however as you're interested in the concept, I'd use SSIS or some other option rather than BULK INSERT, unless it was a one-off import. And in that case I'd just use the basic data import.

G

There are two ways to write error-free programs; only the third one works.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close