Why sql convert number to '*' charachter

I run this query in SQL Server 2008

declare @a varchar(1) select @a = 22 select @a 

he returns it

 * 

why does this query do this result?

+4
source share
3 answers

You will convert 2 characters to a field with 1 character.

He does not fit.

SQL indicates that data is missing. Otherwise, it only displays 2 , and you do not know if it was the full value or not.

+5
source

insufficient space was found -

 declare @a varchar(2) select @a = 242 select @a 

it will also do it

+3
source

Use the following code:

  declare @a varchar (2)
 select @a = 22
 select @a
+3
source

Source: https://habr.com/ru/post/1380203/


All Articles