0

i have a table which contains 10000 records, now i have added the field for placing the plaintext password, so now i want to update all the records, but should update the new field on the basis of the username... like below.

update users set secdetail = case when username = 'abbas' then 'abbas@123' .... end

i am running this query from .net code, using sqlcommand, whenever i try to refresh the pagem after loading for sometime, i gets a message saying,

The query processor ran out of stack space during query optimization. Please simplify the query

Please help.

1
  • The 'case' (as command) is not in the logic of the sql, is just here to help for few cases, but not for updating 10k records use in it. Follow what Greg suggest.
    – Aristos
    Commented Nov 9, 2011 at 1:51

1 Answer 1

1

Why not create a loop in your .net code to produce proper sql update statements separated by semicolins

Update Users Set Secdetail = 'abbas@123' Where Username = 'abbas';
Update Users Set Secdetail = 'bbbas@123' Where Username = 'bbbas';
Update Users Set Secdetail = 'cbbas@123' Where Username = 'cbbas';
...
1
  • This says you shouldn't use case statements for large datasets
    – Greg
    Commented Nov 8, 2011 at 23:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.