SQL Unexpected return value

stoymigo

Senior Member
Joined
Dec 11, 2008
Messages
975
Reaction score
26
I created a sql-scalar function, but you can copy&paste the code below because it does the same:
Code:
Declare @Varchie as Varchar
Set @Varchie = '51'
Select @Varchie

This returns 5, why not 51?

Thx
 
Ok, someone told me that Varchar is same as Varchar(1), so I made it Varchar(50) and it works.
 
You need to set the size of the variable.

Code:
Declare @Varchie as Varchar(2)
Set @Varchie = '51'
Select @Varchie

Edit: Glad you're sorted.
 
Top
Sign up to the MyBroadband newsletter
X