简体   繁体   中英

SQL Server, how to merge two columns into one column?

I have a SQL query

SELECT TABLE_SCHEMA + TABLE_NAME AS ColumnZ 
FROM information_schema.tables

I want the result should be table_Schema.table_name .

help me please!!

Try this:

SELECT TABLE_SCHEMA + '.' + TABLE_NAME AS ColumnZ 
FROM information_schema.tables
SELECT CONCAT(TABLE_SCHEMA, '.', TABLE_NAME) AS ColumnZ FROM information_schema.tables

This code work for you try this....

SELECT Title,
FirstName,
lastName, 
ISNULL(Title,'') + ' ' + ISNULL(FirstName,'') + ' ' + ISNULL(LastName,'') as FullName 
FROM Customer

From SQL Server 2017 onwards, there is CONCAT_WS operator, to concatenate with separators.

SELECT CONCAT_WS('.', TABLE_SCHEMA ,TABLE_NAME) AS ColumnZ 
FROM information_schema.tables

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM