Solve Puzzle about Data type – SQL in Sixty Seconds #108

A very interesting puzzle, where you see the data type conversion in action. I have previously blogged about this puzzle and had received amazing feedback about it. Lots of people realize that they do not know why this particular behaviour is happening in the SQL Server.

Based on a request from the audience and friends, I have decided to build this video based on the puzzle. Let us see if you can solve this very fundamental yet extremely interesting puzzle or not.

Here is the script which I had used in this puzzle.

-- Find your answer at 
DECLARE @PhoneNumber VARCHAR(8) 
SET @PhoneNumber='123456789'
SELECT @PhoneNumber AS PhoneNo
DECLARE @PhoneNumber VARCHAR(8) 
SET @PhoneNumber=123456789
SELECT @PhoneNumber AS PhoneNo

When you run the code above you will get a result similar to the following. While we all expected that the value will be truncated but it actually displays us a *. The question is why star and no other value.

Leave your answer in the comment section. If you want a hint, I have included that in the video. If you want an answer, you can find that on this blog only by searching for data type keyword it there. I am not going to give you a direct link, you have to work for it.

You can subscribe to my YouTube channel for more fun stuff.

Reference: Pinal Dave (

Data Type, SQL in Sixty Seconds, SQL Scripts, SQL Server
Previous Post
Move TempDB for Performance – SQL in Sixty Seconds #107
Next Post
Undo Human Errors in SQL Server – SQL in Sixty Seconds #109 – Point in Time Restore

Related Posts

2 Comments. Leave new

Leave a ReplyCancel reply

Exit mobile version