473,383 Members | 1,984 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,383 software developers and data experts.

Converting number to text for concatenation

12
Hi all,

I'm trying to create a unique identifier field in my table but the two fields I'm trying to concatenate are numbers.

When I write "nhsnumber + diffdate as a_sid" it tries to add the fields together rather than concatenating them.

I've tried converting them into varchars and chars and it's still doing the same thing.

How can I convert these to text so that they can concatenated?

Thanks

Sunny
Jan 16 '12 #1

✓ answered by Jinzuku

Thanks all for your help but I've managed to figure it out. The reason I was having issues was because I was trying to convert them to char or varchar, but what I really needed to convert them to was nvarchar and then concatenate them.

Still not overly sure what the difference between varchar and nvarchar is but at least it works :D

5 3319
C CSR
144 100+
What language, what are the original datatypes, etc?
Jan 16 '12 #2
NeoPa
32,556 Expert Mod 16PB
I'd use CAST() to convert both your fields to string before using the concatenation character + (which is also the addition character for numerics of course).
Jan 17 '12 #3
ck9663
2,878 Expert 2GB
It's because you convert after you add the values. Convert the values then concatenate them.

Good Luck!!!


~~ CK
Jan 17 '12 #4
Jinzuku
12
Thanks all for your help but I've managed to figure it out. The reason I was having issues was because I was trying to convert them to char or varchar, but what I really needed to convert them to was nvarchar and then concatenate them.

Still not overly sure what the difference between varchar and nvarchar is but at least it works :D
Jan 18 '12 #5
NeoPa
32,556 Expert Mod 16PB
The difference is that char and varchar hold the characters as unicode values (16 bits) rather than the ASCII (8 bits) of the nchar and nvarchar types.
Jan 18 '12 #6

Sign in to post your reply or Sign up for a free account.

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: 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: 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: 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...
3
by: GM | last post by:
I am building the text for a resume section label in databinding with 20 or so data columns using a series of 20 or so code snippits like the following: If e.Item.DataItem("EmployerDisplay") And...
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.