Hi VB_DBA!
Thanks a lot for the reply. Sorry for disturbing you again...
Instead of printing, can you please return the @maxid as the OUTPUT parameter? I've tried to assign the value of @maxid to another variable, but it is giving an error:

Couldn't assign a varchar value to int datatype.

Please help.