Solved

How can I generate a table in sql from a .txt file?

Posted on 2009-07-06
6
224 Views
Last Modified: 2012-05-07
I have a tab-delimited text file with something like 66 columns/fields from amazon.  I want to generate a table so that I don't have to explicitly define it myself much like I can do in Excel. However, I have created a program that writes an Schema.ini file that already explicity describes the file from which I make an OldDbConnection, OleDbDataAdapter, and subsequently fill into a dataSeta.  So , I believe I have a couple options?  Thanks.
0
Comment
Question by:MotoDev
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 22

Expert Comment

by:8080_Diver
ID: 24790488
First, some questions:
  1. Does the CSV file have column names?
  2. Are the Text columns enclosed in quotes?
  3. Are there any embedded commas in any of the text fields?
While it is possible to do this in a stored proc, I would be tempted to use an application to accomplish this task simply because this is the sort of thing that can be done well and easily in an application and may not be quite as easy in a stored proc.  (Remember, SQL works on sets of data rather than on individual lines/records and, therefore, one has to be able to treat the data asa set. ;-)
0
 

Author Comment

by:MotoDev
ID: 24790616
To answer your questions: Yes, the .txt file has column names in the first or header line, No, there are no quotes. (Ps I hate quotes). Yes, there are commas.

First, some questions: Does the CSV file have column names?  Are the Text columns enclosed in quotes?  Are there any embedded commas in any of the text fields?  And, I failed to mention I do have an application written in VS 2008 C#. Any thoughts...?

While it is possible to do this in a stored proc, I would be tempted to use an application to accomplish this task simply because this is the sort of thing that can be done well and easily in an application and may not be quite as easy in a stored proc.  (Remember, SQL works on sets of data rather than on individual lines/records and, therefore, one has to be able to treat the data asa set. ;-)
0
 

Author Comment

by:MotoDev
ID: 24793600
I found my answer under the title 'Get data from a Dataset into SQL Server 2000'
0
Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

 
LVL 22

Expert Comment

by:8080_Diver
ID: 24800308
To answer your questions: Yes, the .txt file has column names in the first or header line, No, there are no quotes. (Ps I hate quotes). Yes, there are commas.
You may want to be careful, though.  Having a comma in the middle of a text column turns that text column into 2 text columns unless the text is wrapped in qoutes.  (You may hate quotes but they are useful for this sort of thing. ;-)
 
0
 

Author Comment

by:MotoDev
ID: 24803491
I would still like to see it done.
0
 

Accepted Solution

by:
MotoDev earned 0 total points
ID: 24803559
Just to clarify, The text file is Tab-delimited.  And I can pull the dataset(66 fields and data) into datagrid.  Is their a way to create a sql table in C#?
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This is about my first experience with programming Arduino.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Introduction to Processes

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question