Tuesday, 5 July 2016

Interview Question - What will be the output of .... ? LEN() function

This blog is about what happens when we do not pay attention to Microsoft documentation ... 

Recently, I had a simple question fielded to me which made me look STUPID.. Well being stupid is my right as a human being :) but making me look one is a different thing altogether ... I hope you guys are with me on this :) .... Here comes the bazoooooooooka 

What will be the output of following SQL statements ?

  • SELECT LEN(' ') as 'single Tab' 
  • SELECT LEN('    ') as 'multiple spaces' 
  • SELECT LEN('    ') as 'tab followed by 3 spaces' 
  • SELECT LEN(' ') as '3 spaces followed by tab' 
  • SELECT LEN('   a') as '3 spaces followed by char' 
  • SELECT LEN(' ') as 'space tab space' 
  • SELECT LEN(' a ') as 'space char space' 

Simple isn't it ....


Well if you guess the output of each of these correct then BRAVO, if not then you'll know how does it feel when simple thing such as this stumps you..


Before we see the output of these statements 
this is what BOL says about LEN() function

Now the output 


I hope you did not join me on the podium :) 

No comments:

Post a Comment

bloggerwidgets