SQL Server,如何将两列合并为一列?

时间:2014-08-08 16:13:51

标签: sql sql-server calculated-columns

我有一个SQL查询

SELECT TABLE_SCHEMA + TABLE_NAME AS ColumnZ 
FROM information_schema.tables

我希望结果应为table_Schema.table_name

请帮助我!!

4 个答案:

答案 0 :(得分:13)

试试这个:

SELECT TABLE_SCHEMA + '.' + TABLE_NAME AS ColumnZ 
FROM information_schema.tables

答案 1 :(得分:2)

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

答案 2 :(得分:2)

这段代码适合你试试....

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

答案 3 :(得分:0)

从SQL Server 2017开始,有CONCAT_WS运算符与分隔符连接。

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