Solved

convert ALN to AMOUNT

Posted on 2006-07-20
7
313 Views
Last Modified: 2008-02-01
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
Comment
Question by:rutgermons
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 17144689
SET ALN = cAST([field A] as int ) + CAST( [field B] as int)
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17144694
I don't know data type ALN in Microsoft SQL Server....
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 17144697
I thought ALN is the name of the column...
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 25

Expert Comment

by:Mr_Peerapol
ID: 17144698
Sorry, I don't what ALN is. But try this:

CONVERT(INT, fieldA) + CONVERT(INT, fieldB)
0
 
LVL 30

Accepted Solution

by:
nmcdermaid earned 500 total points
ID: 17144704
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
 
LVL 25

Expert Comment

by:Mr_Peerapol
ID: 17144708
>> value to AMOUNT <<
Maybe:

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

Or:

CONVERT(NUMERIC(17, 2), fieldA) + CONVERT(NUMERIC(17, 2), fieldB)
0
 
LVL 12

Expert Comment

by:Einstine98
ID: 17144713
so everyone never heard of type ALN but heard of Amount? what is this "amount" type?
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how the fundamental information of how to create a table.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question