?
Solved

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

Posted on 2009-07-06
6
Medium Priority
?
225 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
What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

 
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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
Simple Linear Regression
Starting up a Project

764 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