Hi , I have 2 columns named
1. Tel_H
2. Tel_H_Code
How can i merge these two columns to make them one ??
I am clueless here...The best i can do is to view them as one
SELECT Tel_H_Code + Tel_H AS 'Tel_H'
FROM Detailed_List
Hi , I have 2 columns named
1. Tel_H
2. Tel_H_Code
How can i merge these two columns to make them one ??
I am clueless here...The best i can do is to view them as one
SELECT Tel_H_Code + Tel_H AS 'Tel_H'
FROM Detailed_List
maybe you can use select into statement, with it you merge two colums and take it another table like that
SELECT Tel_H_Code + Tel_H AS 'Tel_H' into Table1
FROM Detailed_List
so you can use it
select Tel_H from Table1
try this
SELECT Tel_H_Code + ' ' + Tel_H AS Tel_H
FROM Detailed_List
try this
SELECT Tel_H_Code + ' ' + Tel_H AS Tel_H FROM Detailed_List
this command sums the values of fields!
Let me start by saying that you have ressurected a 3 year old topic. You should have read the warning and let it be. Especially when you don't really know what you are talking about.
The plus symbol (+) has 2 functions:
a) to add when used with numbers
b) to concatenate when used with strings.
The post that you've commented includes a space within quotes, so at best it will produce an error if the Tel_H_Code or Tel_H is a number. If they have been declared as chars then it will just concatenate them.
yes you're right, it's an old topic but many people read this topic that doesn't have a true result.
I tried this command for two numeric fields and it summed them definitely! so the space within quotes didn't work!
the solution is:
Select COALESCE (CAST(Tel_H AS varchar), '') + ' - ' + COALESCE (CAST(Tel_H AS varchar), '') AS Concatenation
from Detailed_List
This worked to combine 2 string values (first name & last name) from 2 separate columns (first_name, last_name) into 1 new column (full_name). Straight out of the textbook: SQL Fundamentals 3rd edition pg. 344:
select employee_id, first_name || ' ' || last_name AS full_name, hire_date
from l_employees;
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.