May 13, 2008 at 4:51 pm
Comments posted to this topic are about the item You are a T-SQL developer who needs to...
May 13, 2008 at 6:03 pm
I'm sure they're looking for an answer on this one, but my answer would be "None of the above"...
1. All of the updates will cause some improper change to properly formatted SSN's.
2. This type of formatting should be done in the GUI, not in the database.
3. If no GUI is present for (2) above, then the formatting should be done in the SELECT... but never in the database.
--Jeff Moden
Change is inevitable... Change for the better is not.
May 13, 2008 at 6:19 pm
I agree with Jeff - but, just to have some fun - I would not use the 'correct' answer for this one. I would use this:
UPDATE Employee
SET SocialSecNumber = stuff(stuff(SocialSecNumber , 6, 0, '-'), 4, 0, '-');
And I probably would do that just to be different 😀
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
May 13, 2008 at 11:13 pm
Me too... except I'd add one thing...
UPDATE Employee
SET SocialSecNumber = stuff(stuff(SocialSecNumber , 6, 0, '-'), 4, 0, '-');
WHERE SocialSecNumber NOT LIKE '%[^0-9]%'
... just to be on the safe side.
--Jeff Moden
Change is inevitable... Change for the better is not.
May 14, 2008 at 12:56 pm
Of course - and probably additional checking to validate that we have 9 characters, etc...
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
May 14, 2008 at 1:05 pm
The QOD can't cover every condition. It's designed in this case to see if you understand SUBSTRING rather than picking the best way to do things.
May 14, 2008 at 1:52 pm
Heh... no problem, Steve... I know about the QOD's and the fact that, like you said, they can't cover every caveat. It's one of those questions that someone asked me on an interview test once... and I gave them the same answer as a penciled in answer after I select the "correct" answer... couldn't resist posting similar here. 😀
The problem with testing in general is that you have to understand that you have to pick the "most" correct answer out of possibly 4 or 5 correct answers and it's not "your" most correct answer... it has to be the answer the test writer thought was most correct. I hate those types of questions... 😛
--Jeff Moden
Change is inevitable... Change for the better is not.
May 14, 2008 at 2:20 pm
Those are the only kinds of questions we can do without an interview.
That's why the interview is important.
December 23, 2015 at 5:47 am
Ha ha ha. You guys are crazy. That's a lot of "stuffing" and it's not even Thanksgiving.
December 23, 2015 at 6:05 am
Iwas Bornready (12/23/2015)
Ha ha ha. You guys are crazy. That's a lot of "stuffing" and it's not even Thanksgiving.
No, but Christmas is just around the corner, and there will be stuffing a-plenty up and down this land...
Thomas Rushton
blog: https://thelonedba.wordpress.com
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply