Strange T-SQL if statement behavior

I have the following T-SQL if statement:

if @changeType = 'ChangeFrom'
 begin
  print 'yep'
 end
else
 begin
  print 'nope'
 end

If @changeType = 'ChangeFrom', I get yep. If @changeType = 'ChangeTo', I get nope. If @changeType ='ChangeFromfsjkfh', I get yep! What is happening there?

+3
source share
1 answer

How long did you declare the variable @ChangeType as ... it looks like it is truncated?

+4
source

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


All Articles