Char variable returns asterisk when inserted value exceeds char length - by jiri_hubacek

Status : 

  By Design<br /><br />
		The product team believes this item works according to its intended design.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 772540 Comments
Status Closed Workarounds
Type Suggestion Repros 0
Opened 11/28/2012 9:17:54 AM
Access Restriction Public


DECLARE @a char(1)
-- @a is null
SELECT @a = 123
select @a

Returns *

Changing the source data type to nchar throws an error:
DECLARE @a nchar(1)
-- @a is null
SELECT @a = 123
select @a

Msg 8115, Level 16, State 2, Line 3
Arithmetic overflow error converting expression to data type nvarchar.

DECLARE @a char(1)
-- @a is null
SELECT @a = '123'
select @a

Truncates the result.

Database Engine version: 10.0.5500, 10.50.4000
Sign in to post a comment.
Posted by Umachandar [MSFT] on 11/29/2012 at 2:22 PM
Thanks for your feedback. The behavior you are seeing is by design.See table "Truncating & Rounding Results" in below link.

Changing it will result in incompatibility with existing applications.

Umachandar, SQL Programmability Team