Monday, August 31, 2009

CAST and CONVERT (Transact-SQL) - Truncating and Rounding Results

Here's some "puzzle" for you dudes .
Before you opening SQL Management Studio and pasting
from clipboard , answer -
what is the result for lines below?


DECLARE @D INT
SET @D = 12345

SELECT CAST(@D AS VARCHAR(2))

2 comments:

  1. I would guess 12...but I'm guessing you wouldn't call it a puzzle if that was the answer...:-)

    ReplyDelete
  2. the answer is not 12 :)
    the tip is the name of a puzzle :
    "CAST and CONVERT (Transact-SQL) - Truncating and Rounding Results" )

    ReplyDelete