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 183601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:08:42+00:00 2026-05-11T15:08:42+00:00

I feel like this might be a crazy question, and if anyone has a

  • 0

I feel like this might be a crazy question, and if anyone has a better idea of how to do it, by all means please let me know.

I have a .Net C# project at work that validates certain tables against the company standards they must adhere to. The tables can be on SQL Server or DB2. When a table is initially added to the program, I gather the metadata/information about the table using select statements off of either information_schema.columns for sql, or syscat.columns for db2. Once I get that data, I store it in a table (let’s call it all_table_information) on sql server containing that same information for every table that is validated in the program.

If the table is a SQL table, I can run this query (of course restricting it to only the columns from the table I want):

insert into [all_table_information]     (table_id, column_name, data_type, max_char_length) select table_id, column_name, data_type, character_maximum_length     from information_schema.columns      where ...restrict to needed table... 

And then execute that in a SqlCommand. But if it is a DB2 table, I have to run this query (restricted again to the columns I need):

select tabschema, tabname, colname, typename, length  from syscat.columns  where ...restrict to needed table... 

Then get a DataReader with the results and loop through it inserting each row using:

while (dr.Read()) {    insert into [all_table_information]    (table_id, column_name, data_type, max_char_length) values     (...''' + dr['whatever'] + '', '' + ....)     ...execute sql here...  }  dr.Close(); 

Doing it this way works, but it is slow, so I was just wondering if there was anyway to do this in one statement? I know you could save the db2 table information to a data table as well, but can you run a query against a data table directly?

Thanks, Ryan

  • 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. 2026-05-11T15:08:43+00:00Added an answer on May 11, 2026 at 3:08 pm

    You probably want to use SqlBulkCopy: MSDN

    It is much faster than doing individual inserts for each row.

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

Sidebar

Related Questions

I feel like this might be really simple but I'm just not getting it
I feel like this is something I should already know, but I'm just not
I feel like this is a stupid question, but I can't think of a
I feel like this is a common problem but nothing I've researched has worked
I might be doing this wrong, if I am, let me know, but I'm
This might seem like a silly question, but after asking some questions on stackoverflow
I feel like this question is so basic that none of the tutorials or
I feel like this is easy but I am missing something... Using jQuery, I
I feel like this should be a no brainer, but clearly I'm missing something...
I feel like this should be obvious to me, but for some reason I

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.