I have a table with a Unique Key on columns Pfx, Bse and Sfx. While inserting data, it seems to me like SQL Server is internally applying an RTRIM and causing an issue with my Sfx column which has a space in the second row. Is it possible to prevent this RTRIM or am I missing something?
INSERT INTO Part (Seq, Pfx, Bse, Sfx, Stat, Desc, Cr_date, Cr_User)
SELECT 1 SEQ, '2R83' AS PFX, '6477' BSE, 'AA' SFX, 1 STAT, 'SPLIT MASS FLYWHEEL' DESCR, GETDATE() CR_DT, 'USERID' CR_US
UNION ALL
SELECT 2, '2R83', '6477', 'AA ', 1, 'SPLIT MASS FLYWHEEL', GETDATE(), 'USERID';
The error message doesn't seem to be trimming the data and retains the space.
Violation of UNIQUE KEY constraint 'NNMP0672'. The duplicate key value is (2R83, 6477, AA )