SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Site Related Forums
 Article Discussion
 Import CSV file
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jwaz1999
Starting Member

12 Posts

Posted - 09/10/2010 :  12:44:58  Show Profile  Reply with Quote
Is there a way that a CSV file can be imported into a SQL Server table using BCP if the file has the below 5 column format, or do you have to iterate through it one record at a time?

sample data:

5, "test, column", "test column 2", 4, "test column, 5"

6, test column", "test column 2,", 5, "test column 5"

7, test column", "test column 2", 6, "test, column 5"


If it can be done with BCP, how do you define the format for columns with quotes(char data) and columns without quotes(int data)?

Thanks,
Jeff

X002548
Not Just a Number

15586 Posts

Posted - 09/10/2010 :  12:59:09  Show Profile  Reply with Quote
No quotes

commas have always been a problem

So is TAB

So is Pipe (|)

Can you do a multivalued delimiter?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

jwaz1999
Starting Member

12 Posts

Posted - 09/10/2010 :  13:16:16  Show Profile  Reply with Quote
Hi Brett,

This is universally accepted way to create a csv file. Check out:
http://en.wikipedia.org/wiki/Comma-separated_values

Quotes are used for character columns, and no quotes are used for integer columns. This way, if the data contains a comma or a double quote, the consuming user will know how to handle it. It makes sense to use this format.

Jeff

quote:
Originally posted by X002548

No quotes

commas have always been a problem

So is TAB

So is Pipe (|)

Can you do a multivalued delimiter?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam





Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 09/10/2010 :  13:25:24  Show Profile  Reply with Quote
quote:
Originally posted by jwaz1999

Hi Brett,

This is universally accepted way to create a csv file. Check out:
http://en.wikipedia.org/wiki/Comma-separated_values




Well good for you with that.

Good Luck



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

jwaz1999
Starting Member

12 Posts

Posted - 09/10/2010 :  13:26:34  Show Profile  Reply with Quote
What do you mean good for me with that? I was just pointing a the "correct" way to create a CSV file? You didn't answer my question.

quote:
Originally posted by X002548

quote:
Originally posted by jwaz1999

Hi Brett,

This is universally accepted way to create a csv file. Check out:
http://en.wikipedia.org/wiki/Comma-separated_values




Well good for you with that.

Good Luck



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam





Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000