December 19, 2008 at 3:04 pm
I have two columns that have integer values. I would like to concatenate them as text and add them to a new column.
here is the code, but it's not working:
select cast (Table.column1 as char(10)) + ' -- ' + cast (Table.column2 as char(10)) as newColumn
Please help.
December 19, 2008 at 3:08 pm
Are you getting an error? If so, what error. If not, what is the result you are getting, and what are you actually looking for?
December 19, 2008 at 5:03 pm
December 20, 2008 at 2:18 am
Lynn Pettis (12/19/2008)
Are you getting an error? If so, what error. If not, what is the result you are getting, and what are you actually looking for?
cast (Table.column1 AS char(10))
The OP's post pre-edit was missing the AS.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
December 20, 2008 at 6:23 am
Now, it's just missing the FROM clause.
--Jeff Moden
Change is inevitable... Change for the better is not.
December 22, 2008 at 8:26 am
thanks for all the help. I don't know what i was doing wrong. It is just working now!
December 22, 2008 at 10:38 am
Can you post what you ended up with, please? Thanks.
--Jeff Moden
Change is inevitable... Change for the better is not.
December 22, 2008 at 11:49 am
select cast (Table.column1 as char(10)) + ' -- ' + cast (Table.column2 as char(10)) as newColumn
from Table
....
December 22, 2008 at 12:27 pm
Comparing that to the original, it looks like all you were missing was the FROM clause.
--Jeff Moden
Change is inevitable... Change for the better is not.
December 22, 2008 at 2:31 pm
No, I was just leaving it out, because it didn't make any difference. Wouldn't it be pointless to write a query without a from clause?!
December 22, 2008 at 3:16 pm
In most cases, yeah...
In that case, I dunno what the original problem was.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply