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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:15:33+00:00 2026-05-14T19:15:33+00:00

Currently I have a sql call returning a dataset from a MSSQL database and

  • 0

Currently I have a sql call returning a dataset from a MSSQL database and I want to take a column from that data and return ID’s based off that column from the ORACLE database. I can do this one at a time but that requires multiple calls, I am wondering if this can be done with one call.

String sql=String.Format(@"Select DIST_NO
    FROM DISTRICT
    WHERE DIST_DESC = '{0}'", row.Table.Rows[0]["Op_Centre"].ToString());

Above is the string I am using to return one ID at a time. I know the {0} can be used to format your value into the string and maybe there is a way to do that with a datatable.

Also to use multiple values in the where clause it would be:

String sql=String.Format(@"Select DIST_NO
   FROM DISTRICT
   WHERE DIST_DESC in ('{0}')", row.Table.Rows[0] ["Op_Centre"].ToString());

Although I realize all of this can be done I am wondering if theres an easy way to add it all to the sql string in one call.

As I am writing this I am realizing I could break the string into sections then just add every row value to the SQL string within the “WHERE DIST_DESC IN (” clause…

I am still curious to see if there is another way though, and because someone else may come across this problem I will post a solution if I develop one.

Thanks in advance.

  • 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-05-14T19:15:34+00:00Added an answer on May 14, 2026 at 7:15 pm

    The most RDBMS-agnostic approach you could do is to create a temporary table. Then just query: select * from district where dist_desc in (select dist_desc from temp_table)

    There’s a solution here in Oracle http://forums.oracle.com/forums/thread.jspa?threadID=930372 , but I don’t have Oracle in my box, so I can’t try how it will work in .NET.

    Have tried this in Postgresql http://fxjr.blogspot.com/2009/05/npgsql-tips-using-in-queries-with.html , have very seamless support for comparing value to list

    If you will go the dynamic query approach, try this:

    String sql=String.Format(@"Select DIST_NO
    FROM DISTRICT
    WHERE DIST_DESC IN ({0})", 
      string.Join( ",",
          ds.Tables[0].Select()
          .Select(r => "'" + (string)r["Op_Centre"] + "'").ToArray() ) // string.Join
      ); // string.Format
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 379k
  • Answers 379k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Your greedy algorithm IS correct. We can prove this by… May 14, 2026 at 9:29 pm
  • Editorial Team
    Editorial Team added an answer There are two accurate methods for timing functions: Single process… May 14, 2026 at 9:29 pm
  • Editorial Team
    Editorial Team added an answer http://markphip.blogspot.com/2006/12/subversion-moverename-feature.html Rename is a copy / delete If a rename… May 14, 2026 at 9:29 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.