on 06-01-2011 8:58 AM
hi all,
i am using this query to convert inches to cm
Declare @a as nvarchar
Declare @b as nvarchar
Declare @c as nvarchar
Declare @d as nvarchar
Declare @e as nvarchar
Declare @f as nvarchar
Declare @g as nvarchar
Declare @h as nvarchar
set @a=convert(Numeric(10),(($[@SIZETABLE.U_LEN.number])/2.54))
set @b=convert(Numeric(10),(($[@SIZETABLE.U_width.number])/2.54))
set @c=convert(Numeric(10),(($[@SIZETABLE.U_hgt.number])/2.54))
set @d=convert(Numeric(10),(($[@SIZETABLE.U_dia.number])/2.54))
set @e=convert(Numeric(10),(($[@SIZETABLE.U_thick.number])/2.54))
set @f=convert(Numeric(10),(($[@SIZETABLE.U_bag.number])/2.54))
set @g=convert(Numeric(10),(($[@SIZETABLE.U_garment.number])/2.54))
set @h=convert(Numeric(10),(($[@SIZETABLE.U_size.number])/2.54))
SELECT case when @a='' then '' else @a+'L'
end + case when @b='0' then '' else 'x'+ @b
+'w' end+case when @c ='0' then '' else 'x'+@c
+'h' end+case when @d='0' then '' else 'x'+@d+
'd' end+case when @e='0' then '' else 'x'+@e+
't' end+case when @f='0' then '' else 'x'+@f+'b' end+
' '+rtrim($[@sizetable.U_unit]) + case when @g='0' then '' else ','+
@g+'g' end+case when @h='0' then '' else ','+
@h+'s' end
this query is working fine for numeric(10) but i want result upto 2 decimal place when i am convert it to numeric(10,2) it gives me error 'Arithmetic overflow error converting nvarchar to data type numeric'. plz suggest me.
thanks
Rahul
Try to change the expression @a='' to @a='0' ' !
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
all the fields in sap is nvarchar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi rahul sagar
you can try:
set @a=convert(Nvarchar(100), CONVERT(FLOAT, $[@SIZETABLE.U_LEN.number] /2.54 ) )
you result was rounded with 0 decimal because type of U_LEN feild is Interger, so the division as it will automatically convert to int.
thanks
H2
Edited by: Hoe Pham Huy on Jun 1, 2011 4:29 PM
User | Count |
---|---|
98 | |
12 | |
10 | |
6 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.