Solved

convert ALN to AMOUNT

Posted on 2006-07-20
7
308 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
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 142

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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

920 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now