Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MS SQL unique key - bug or feature?

I have a table in MS SQL where I have a TERMINAL varchar(50) column and I have a unique key on it. I get a UK key violation exception when I try to insert record 'HOST1' and then 'HOST1 '. Why MS sql handles these two strings as they would be the same?

Thanks Z

like image 659
HamoriZ Avatar asked Jul 04 '26 17:07

HamoriZ


1 Answers

I believe that MS SQL strips the white space at the end for VARCHAR.

like image 127
James Culshaw Avatar answered Jul 07 '26 07:07

James Culshaw