473,405 Members | 2,294 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Converting Number to Text

Hi,

I have two tables. One of them has a text field, and the other has a numeric
(integer) field that serves a similar purpose. I want to connect (UNION
actually) the two tables, and store the text from the first table in the
same field as the number from the other.

For example:
SELECT TextID AS ID
FROM W1
UNION
SELECT NumericID AS ID
FROM W2

The above query results in a type mismatch error due to trying to store an
Int in a text field. I have tried the SQL CONVERT function, but the docs
seem to indicate that it is just for Dates. In any case, it hasn't worked
for me.

Any ideas?
Thanks!
Jul 20 '05 #1
3 142329
HumanJHawkins wrote:
Hi,

I have two tables. One of them has a text field, and the other has a numeric
(integer) field that serves a similar purpose. I want to connect (UNION
actually) the two tables, and store the text from the first table in the
same field as the number from the other.

For example:
SELECT TextID AS ID
FROM W1
UNION
SELECT NumericID AS ID
FROM W2

The above query results in a type mismatch error due to trying to store an
Int in a text field. I have tried the SQL CONVERT function, but the docs
seem to indicate that it is just for Dates. In any case, it hasn't worked
for me.


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
What db are you working in SQL server or Access (JET)?

SQL'r:

SELECT TextID AS ID
FROM W1
UNION
SELECT CAST(NumericID As VARCHAR(20)) AS ID
FROM W2

Or, if you like CONVERT():

CONVERT(VARCHAR(20), NumericID)

Access:

SELECT TextID AS ID
FROM W1
UNION
SELECT CStr(NumericID)
FROM W2

- --
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQG40H4echKqOuFEgEQII0wCgiMyVf3hCs8jWqZ07WscJzN nvfREAn01H
HiEh8gvGqSaM0Tq5L2yY2T4m
=cLy3
-----END PGP SIGNATURE-----

Jul 20 '05 #2
Try Str():
... UNION SELECT Str(NumericID) AS ID ...

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"HumanJHawkins" <JH******@HumanitiesSoftware.Com> wrote in message
news:kH*******************@newsread1.news.pas.eart hlink.net...
Hi,

I have two tables. One of them has a text field, and the other has a numeric (integer) field that serves a similar purpose. I want to connect (UNION
actually) the two tables, and store the text from the first table in the
same field as the number from the other.

For example:
SELECT TextID AS ID
FROM W1
UNION
SELECT NumericID AS ID
FROM W2

The above query results in a type mismatch error due to trying to store an
Int in a text field. I have tried the SQL CONVERT function, but the docs
seem to indicate that it is just for Dates. In any case, it hasn't worked
for me.

Any ideas?
Thanks!

Jul 20 '05 #3
"HumanJHawkins" <JH******@HumanitiesSoftware.Com> wrote in
news:kH*******************@newsread1.news.pas.eart hlink.net:
Hi,

I have two tables. One of them has a text field, and the other
has a numeric (integer) field that serves a similar purpose. I
want to connect (UNION actually) the two tables, and store the
text from the first table in the same field as the number from
the other.

For example:
SELECT TextID AS ID
FROM W1
UNION
SELECT NumericID AS ID
FROM W2

The above query results in a type mismatch error due to trying
to store an Int in a text field. I have tried the SQL CONVERT
function, but the docs seem to indicate that it is just for
Dates. In any case, it hasn't worked for me.

Any ideas?
Thanks!

You could wrap the numericID field in the format() function. This
returns a text string. Or wrap it in the Cstr() function.

Bob Q
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sven Mayer | last post by:
Assume a database (e.g. Oracle) field is declared as a) NUMBER (length=10) b) NUMBER (length=26) c) VARCHAR2 (length=1) d) VARCHAR2 (length=50) e) DATE How do I retrieve the contents from...
3
by: Ciar?n | last post by:
I have a table with over a million rows and one of the fields contains amounts of money in text format. What is the most efficient way of converting this field to a number format that I can sum...
5
by: Mukesh Kumar | last post by:
hi I am trying to pass range parameters to crystal reports from my .net environment. The start and end values of the range parameters are of currency type. I need to convert the number to currency...
3
by: HumanJHawkins | last post by:
Hi, I have two tables. One of them has a text field, and the other has a numeric (integer) field that serves a similar purpose. I want to connect (UNION actually) the two tables, and store the...
3
by: Homer Simpson | last post by:
How do I convert a value in a textbox to a real number so I can perform some math ops on it? I understand I will need to validate the textbox's input to make sure it is a real number and not a...
2
by: mac | last post by:
Assume you have a textbox named "displayValue" What is the difference (if any) between these two approaches: 1.) float var; var = 0.42F; displayValue.Text = var.ToString 2.)
7
anukagni
by: anukagni | last post by:
Hi friends, I want to get this thing happen.. I want to convert the number to word i.e. if i entry 1 in an text box then it should give the reflect to One in an lable .. Is this possible...
5
by: ria3 | last post by:
Hi, I have to write a program that will alow the user to specify a number (decimal, binary, or hexadecimal) and a base to convert to (decimal, binary, or hexadecimal) using subroutine methods and...
0
by: Tania Louie | last post by:
Hi, I just need help coverting a number to a time in SQL. Currently it is returning a number of 1260 for the time and I need it to show as the actual time of 9:30. Not sure what to use here....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.