gstackoverflow
gstackoverflow

Reputation: 37078

sql print returns strange result

I have the following sql code:

DECLARE @result VARCHAR
SET @result = 'FN'
print(@result)      

It returns F to console. why?

Upvotes: 0

Views: 36

Answers (1)

HoneyBadger
HoneyBadger

Reputation: 15150

If you define a VARCHAR, you have to specify it's length. If you don't it defaults to 1.

Use:

DECLARE @result VARCHAR(2)
SET @result = 'FN'
print(@result)

Upvotes: 2

Related Questions