You care declaring batchid
as a char
:
declare @batchid char (30)
select @batchid='13857584' --enter batch id here
In fact, the batchid is being set to something like:
'13857584______________________'
The underscores are intended to show the space character, not an actual underscore.
Try changing it to varchar()
:
declare @batchid varchar(30);
select @batchid = '13857584'; --enter batch id here