[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 332
  • Last Modified:

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
0
rutgermons
Asked:
rutgermons
1 Solution
 
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
 
Aneesh RetnakaranDatabase AdministratorCommented:
I thought ALN is the name of the column...
0
Upgrade your Question Security!

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

 
Mr_PeerapolCommented:
Sorry, I don't what ALN is. But try this:

CONVERT(INT, fieldA) + CONVERT(INT, fieldB)
0
 
nmcdermaidCommented:
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
 
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

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now