Why does this query return *?

Asked

Viewed 185 times

7

Why this query returns to me *?

select convert(varchar(2), 141)

I thought it was the ascii table, but the 141 doesn’t match the *.

Utilise SQL Server 2008 R2

  • 1

    Which bank are you using?

  • 1

    I think it depends on the collate. The * can be because it does not have a valid character to print.

  • @Jéfersontavares SQL Server 2008 R2

1 answer

9


When integers are converted implicitly to a type of character data, if the integer is too large to fit into the character field, SQL Server returns character 42 of the ASCII Table, the asterisk (*).

Soon any number with the size greater than 2 characters will return *. If you want to display the 141 just increase the number of characters:

select convert(varchar(3), 141)

Return: 141.

Source: Technet

Browser other questions tagged

You are not signed in. Login or sign up in order to post.