SQL Server Performance Forum – Threads Archive
Check the existed data in table by order !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.
Read about CASE expression in sql server help file Madhivanan Failing to plan is Planning to fail
Continue your discussions here
http://sql-server-performance.com/forum/topic.asp?TOPIC_ID=22228 Madhivanan Failing to plan is Planning to fail
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.