March 6, 2015 at 10:11 am
We're converting to new student info system. Sometimes registrar entered the same school into the schools table but spelled it differently. Trying to find all student assigned transfer credits from the same school but the school name is different. My db shows a max of 9 different schools students have rec'd transfer credits. Spending too much time trying to figure out best way to do it w/o a ton of IF stmts. Looking at Soundex and Difference functions. Still looks like a lot of coding. Anyone know how to compare up to 9 string variables in sqlserver 2008?
Thanks
Ivy Pearsall
UAMS
March 6, 2015 at 2:51 pm
hi iapearsall,
I'm not sure I really understand what you are trying to do but, I'll give an answer a shot.
How many variations of the school name do you have?
If the 9 schools you mention are the number of variations, is it possible to do a quick update statement on the table in question?
For example,
UPDATE SchoolTable
SET SchoolName = "X"
WHERE SchoolName = "A" OR SchoolName = "B"... etc?
I may be thinking of this in too simple of terms.
Let me know! 🙂
~Steve
March 7, 2015 at 7:13 am
Ended up using the Difference function. Know I could have created another function and not use so many 'or' operators, but this is just going to be executed a few times. Max # of 'or' were when school count = 9
If @NbrSchools = 9
IfDifference(@s1,@s2) = 4 or
Difference(@s1,@s3) = 4 or
Difference(@s1,@s4) = 4 or
Difference(@s1,@s5) = 4 or
Difference(@s1,@s6) = 4 or
Difference(@s1,@s7) = 4 or
Difference(@s1,@s8) = 4 or
Difference(@s1,@s9) = 4 or
Difference(@s2,@s3) = 4 or
Difference(@s2,@s4) = 4 or
Difference(@s2,@s5) = 4 or
Difference(@s2,@s6) = 4 or
Difference(@s2,@s7) = 4 or
Difference(@s2,@s8) = 4 or
Difference(@s2,@s9) = 4 or
Difference(@s3,@s4) = 4 or
Difference(@s3,@s5) = 4 or
Difference(@s3,@s6) = 4 or
Difference(@s3,@s7) = 4 or
Difference(@s3,@s8) = 4 or
Difference(@s3,@s9) = 4 or
Difference(@s4,@s5) = 4 or
Difference(@s4,@s6) = 4 or
Difference(@s4,@s7) = 4 or
Difference(@s4,@s8) = 4 or
Difference(@s4,@s9) = 4 or
Difference(@s5,@s6) = 4 or
Difference(@s5,@s7) = 4 or
Difference(@s5,@s8) = 4 or
Difference(@s5,@s9) = 4 or
Difference(@s6,@s7) = 4 or
Difference(@s6,@s8) = 4 or
Difference(@s6,@s9) = 4 or
Difference(@s7,@s8) = 4 or
Difference(@s7,@s9) = 4 or
Difference(@s8,@s9) = 4
Update Gus.TransferCredits Set ErrorCode = 1 Where UAMSID = @Student_UAMSID
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply