May 20, 2011 at 12:27 am
Hi,
I have a very interesting query asked to me and the he asked me if there is a table specifying gender (M AND F) and admin entered M as F and F as M by mistake ..for exampel:
Table (let 50000 records )
Name gender
Mr.ABC F
MRS XYZ M
and now we need to change M to F and F to M.please help ...i m very very new to it
May 20, 2011 at 12:39 am
Use Case statment to update the wrong Entered data
May 20, 2011 at 12:45 am
If i add case and change M to F and F to M ...loop will not terminate...if i first convert m to f and back f to m will create problem,...however thanks so much i try with case ..
May 20, 2011 at 8:39 am
You should NOT use a loop for an update statement. Try something like this.
update MyTable set Gender = case Gender when 'M' then 'F' when 'F' then 'M' end
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
May 20, 2011 at 12:37 pm
Is every single record wrong ?
If not, how will you identify which ones need fixing ?
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply