• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 258
  • Last Modified:

Best practice using in-clause in sql server 2005

Hi,

I have an  update statement with where condition as follows

update tableA
set c1='cccc'
where id in ( x number of ids )

In the above where condition if  suppose I have 50 id's , do i need hard code all the id's  or
is there any best approach  to do this with good performance.

Any help would be appreciated.
0
dsk1234
Asked:
dsk1234
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>if  suppose I have 50 id's
where do those "id" values come from.

the answer to your question lies in that information.
if it comes from a user input, check this article: http://www.experts-exchange.com/A_1536.html

if it is a "hard-coded list", which might though vary, I would put the list into a table, and do:
update tableA
set c1='cccc'
where id in ( select id from that_lookup_table )

Open in new window


0
 
dsk1234Author Commented:
Id's are hard coded list  , but the list (ids) are not specific to one table.I just need to update the column for all hard codes ids.

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now