# Database Discussions > Microsoft SQL Server 2008 >  Query hellp

## khan16

Hi,




I have the below statement. It is suppose to return the following format

mmddyy000 00 (with the 000 & 00 field being up to 3 & 2 fields and padded with zeroes if not respectively)

I am getting the following error message :

Conversion failed when converting the varchar value 'OOO' to data type smallint.




This is the statement:


REPLICATE


('0',50-DATALENGTH(REPLACE(CONVERT(CHAR(8), A.BATDAT, 1), '/', '') + RIGHT('OOO'+ A.BATSEQ,3 ) + RIGHT('00' + A.SEQNBR,2)))+REPLACE(CONVERT(CHAR(8), A.BATDAT, 1), '/', '') + RIGHT('OOO'+ A.BATSEQ,3) + RIGHT('00' + A.SEQNBR,2) AS man_ID,

REPLICATE


('0',50-DATALENGTH(REPLACE(CONVERT(CHAR(8), A.BATDAT, 1), '/', '') + RIGHT('OOO'+ A.BATSEQ,3 ) + RIGHT('00' + A.SEQNBR,2)))+REPLACE(CONVERT(CHAR(8), A.BATDAT, 1), '/', '') + RIGHT('OOO'+ A.BATSEQ,3) + RIGHT('00' + A.SEQNBR,2) AS CLAIM_ID,

----------

