Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to determine the value of a field after it has been selected from a varchar field of 1 table and converted to an INT type value and inserted into another Sybase table with a field type of INT ?

Posted on 2016-11-09
2
Medium Priority
?
135 Views
Last Modified: 2016-11-09
I am inserting records into a Sybase Table using
I am using a C# program to read in the records from a txt file named InputFile.txt into a Sybase table titled tableA.
One of the fields I read into tableA has a title "age" which has a datatype of varchar(3).
Let's say I read in the records as follows:

                   while ((line = file.ReadLine()) != null)
                    {
                        DataRow row = dt.NewRow();
                        row["age"] = line.Substring(45, 3);

Then I select the records from tableA insert them into another table, tableB that has a field titled "AgeDays" that is an INT type field. This is carried out as follows:

INSERT INTO tableB (
            AgeDays  )      
           SELECT
           CONVERT(INT, W.age) * 1 AS Expr4

If a record in the InputFile.txt has an Age value of '000' that is imported into the field tableA.age, what value would appear in tableB.AgeDays after the insertion statement is executed?
0
Comment
Question by:zimmer9
[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
2 Comments
 
LVL 41

Accepted Solution

by:
Kyle Abrahams earned 2000 total points
ID: 41881093
000 is cast to 0 . . . 0 * 1 = 0.
0
 
LVL 27

Expert Comment

by:wilcoxon
ID: 41881132
Since it is being inserted into an int field, the value will have all leading 0s stripped (000 -> 0, 001 -> 1, 010 -> 10, etc).
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

610 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