Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

convert ALN to AMOUNT

Posted on 2006-07-20
7
Medium Priority
?
322 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 2000 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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
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.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

721 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