Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8305133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:00:50+00:00 2026-06-08T18:00:50+00:00

I already have some tables in SQL Server and I am writing a C#

  • 0

I already have some tables in SQL Server and I am writing a C# program to populate the tables from some flat files. I plan to use SQLBulkCopy to load the tables.

It can be a lot of work to define all the columns for each DataTable for SQLBulkCopy. Is it a easy way to generate these DataTables in C# from the definition of the existed SQL Server tables?


I cannot use Bulk insert or bcp because the flat files are in different strange layout and they had to be parsed by some C# code before inserting.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T18:00:52+00:00Added an answer on June 8, 2026 at 6:00 pm

    If you want the brute force approach, you could use the following for every table:

        DataTable dt = new DataTable();
        using (SqlConnection conn = new SqlConnection("Some SQLConnectionString")) {
            conn.Open();
            using (SqlDataAdapter adapter = new SqlDataAdapter("SELECT TOP 0 * FROM SomeTable", conn))
            {
                adapter.Fill(dt);
            };
        };
    

    The SELECT TOP 0 will return only the table structure with no records.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like some help writing the following sproc: I have SQL Server 2008 sproc
I'd appreciate some advice from SQL Server gurus here. Let me explain... I have
I have some large tables (millions of rows). I constantly receive files containing new
I'm about to have to rewrite some rather old code using SQL Server's BULK
I'm not a DBA, but I have some basic understanding about how SQL Server
I have a database in ms-sql-server express 2008 which is accessed with linq-to-sql from
I'm having some trouble with and sql server many to many relationship, i already
I have already some applets ready. I tried to run it on android tablet.
I have a data table which already has some values, plus it is getting
I have a table which already contains an index in MySQL. I added some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.