convert ALN to AMOUNT

folks

how do i convert a ALN field type value to AMOUNT

I have two fields both numerical values but there field type is ALN

if I add then eg

field A + field B

then I get
11 as it gets concatenated

I require

2 eg 1 plus 1

all help will do
rutgermonsAsked:
Who is Participating?
 
nmcdermaidConnect With a Mentor Commented:
I've never heard of an ALN field.

But if its a varchar field (which is what it looks like) then use this:


CONVERT(INT,A) + CONVERT(INT,B)


The only problem is that you can put a letter into a varchar field, and of course you can't add a letter to a number - an error results.

Therefore this is more robust:

SELECT
CONVERT(INT,A) + CONVERT(INT,B)
FROM YourTable
WHERE
ISNUMERIC(A) =1 AND ISNUMERIC(B) = 1
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
SET ALN = cAST([field A] as int ) + CAST( [field B] as int)
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
I don't know data type ALN in Microsoft SQL Server....
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
Aneesh RetnakaranDatabase AdministratorCommented:
I thought ALN is the name of the column...
0
 
Mr_PeerapolCommented:
Sorry, I don't what ALN is. But try this:

CONVERT(INT, fieldA) + CONVERT(INT, fieldB)
0
 
Mr_PeerapolCommented:
>> value to AMOUNT <<
Maybe:

CONVERT(MONEY, fieldA) + CONVERT(MONEY, fieldB)

Or:

CONVERT(NUMERIC(17, 2), fieldA) + CONVERT(NUMERIC(17, 2), fieldB)
0
 
Einstine98Commented:
so everyone never heard of type ALN but heard of Amount? what is this "amount" type?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.