SQL Server Performance

Check the existed data in table by order !

Discussion in 'T-SQL Performance Tuning for Developers' started by avt2k7, Jun 16, 2007.

  1. avt2k7 New Member

    Hello all,

    I got a T-SQL questions to add more codes for checking the existed data in SQL server tables about 700000 records and following the ordering criteria to update existed data in the table.

    My sample table as following:

    ID | lastname | firstname | school | examscore | areacode | grade |
    1 | Snow | Dun | east | 80 | 1 | |
    2 | Tom | Hellman | west | 100 | | |
    3 | Julie | Williams | east | | | |
    4 | Jen | Lee | | | | |


    First check whether or not any null values in school, examscore, and areacode?
    Then updated data in grade column followed the belowed ordering rules:

    1. If school, examscore and areacode are not null; then need to update grade = A
    2. If school, examscore are not null and areacode is null; then need to update grade = B
    3. If school is not null; examscore and areacode are null; then need to update grade = C
    4. If all school, examscore and areacode are null; then need to update grade = D

    I am not sure the SQL commands that implement above conditions. Any actual T-SQL codes is much appriciated. Thanks in advance.

  2. Madhivanan Moderator

    Read about CASE expression in sql server help file


    Failing to plan is Planning to fail
  3. Madhivanan Moderator

  4. satya Moderator

    Follow as suggested and do not post duplicate posts.

    Satya SKJ
    Microsoft SQL Server MVP
    Writer, Contributing Editor & Moderator
    This posting is provided AS IS with no rights for the sake of knowledge sharing. Knowledge is of two kinds. We know a subject ourselves or we know where we can find information on it.

Share This Page