在SQL Server 2005的Select语句中的Concat两列 [英] Concat two column in a select statement sql server 2005

查看:73
本文介绍了在SQL Server 2005的Select语句中的Concat两列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在SQL Server 2005的select语句中连接两列?

How to Concat two column in a select statement sql server 2005?

这是我的声明Select FirstName,secondName from Table ...

Here is my statement Select FirstName,secondName from Table...

现在我确实尝试使用

Select FirstName + ' ' + secondName from Table

但是对于某些记录,secondName列中的某些值是NULL. 返回NULL而不是FirstName ..如果secondName是NULL ..

But some values are NULL in secondName column for some records.. My select statement returns NULL instead of FirstName.. I want to have FirstName if secondName is NULL ..

推荐答案

SELECT FirstName + ISNULL(' ' + SecondName, '') from Table

这篇关于在SQL Server 2005的Select语句中的Concat两列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆