¿Por qué SQL convierte un número en el carácter '*'?

i run this query in SQL Server 2008

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

it's return this

*

why this query make this result ?

preguntado el 08 de noviembre de 11 a las 14:11

Which server? Sql Server or MySql / Oracle? -

3 Respuestas

You are converting a 2 character number into a 1 character field.

It won't fit.

SQL is indicating the data is missing. Otherwise, it would display just a 2 and you wouldn't know if this was the full value or not.

respondido 08 nov., 11:18

@CooLi3oY - because the options are either return a portion of what you entered, which could be misleading, or return a character to indicate that the value is incomplete. It's safer to return the incomplete indicator. - JNK

insufficient space was detected -

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

this will also do that

respondido 08 nov., 11:18

Utilice el siguiente código:

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

respondido 08 nov., 11:18

+1 for right answer but it would help the OP if you also tell him why. - Leones

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.