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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:56:38+00:00 2026-05-25T10:56:38+00:00

I have an SQL Azure database with a table that has JobId primary key.

  • 0

I have an SQL Azure database with a table that has JobId primary key. A user sends in a bunch of “job ids” as an array that can contain one or more (maybe ten, maybe ten thousand) values. I can’t decide how to do write SQL queries for that. I will use .NET framework classes.

One option I see is creating a temp table and doing a WHERE IN nested SELECT (SQL+C#-like pseudocode):

CREATE TEMP TABLE JobIdsTable
foreach( JobId in JobIdsFromClients ) {
   INSERT INTO JobIdsTable VALUES (JobId)
}
SELECT * FROM JobsTable WHERE JobId IN SELECT * FROM JobIdsTable

Here it looks cool from code writing standpoint, but I’m not sure it will always run fast.

Another option is creating a huge OR concatenation forming a giant SELECT:

SELECT * FROM JobsTable WHERE JobId='JobId1' OR JobId='JobId2' OR JobId='JobId3' .....

Here it’s one SELECT but the idea of concatenating this longs string doesn’t sound good (normally I’d use System.Data.SqlClient.SqlCommand.Parameters to build a parameterized query, but here it will be very complicated. Also I’m unsure of whether there’s a limit on how long an SQL query can be.

I’d like my query to be both manageable and performant. So I see drawbacks in both options.

Which do I choose? Do I do it any other way instead?

  • 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-25T10:56:38+00:00Added an answer on May 25, 2026 at 10:56 am

    I’d go with the temp table, but use a join instead of a subquery. if the Id columns are indexed, the performance should be decent:

    SELECT * 
    FROM JobsTable j
    INNER JOIN JobIdsTable jt ON j.JobId = jt.JobId
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an SQL server database that I am querying and I only want
I am trying to use a Database in SQL Azure. I have installed SQL
I have a large (~ 40gb ) SQL Server 2008 database that I would
I have SQL Server 2005 Standard Service Pack 2 9.00.4053.00 (Intel X86) Table has
I have created a database with SQL Azure and everything works fine except for
I have SQL data that looks like this: events id name capacity 1 Cooking
We have SQL Server database setup. We are setting up a replication scenarios where
I have an SQL query that takes the following form: UPDATE foo SET flag=true
I have a SQL script that inserts data (via INSERT statements currently numbering in
I have a client that uses a point-of-sale solution involving an Access database for

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.