由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - 关于SQL Server的string function
相关主题
Re: How to concatenate NULL value with a string in SQL Server?not null in ms sql
新手问题求助请问sql 有条件性的select columns
Urgent SQL problem!SQL Query Question
SQL的一个愚蠢小问题A SQL problem
A simple question for SQL, seeking help求教高手:odbc更新数据出错
How to concatenate NULL value with a string in SQL Server?SQL question(在线等,谢谢!!)
How to get other columns after UNION?请教一下高手,包子答谢!
吃了包子, 幹活了!How to find all duplicate record in SQL?
相关话题的讨论汇总
话题: null话题: lastname话题: isnull话题: gisha话题: john
进入Database版参与讨论
1 (共1页)
j****s
发帖数: 881
1
第一列为姓,第二列为中间名,第三列为名
要把这三列合起来做为一列,关键是第2列有null 值,有时第3列也有null值
怎么忽略这些null值?
需要:
Mack null John ------〉Mack,John
Gisha null null------->Gisha,
Mathews M Peter----->Mathews, M Peter
用select lastName + ', ' + MiddleName + ' '+ LastName from Table
不行,handle不了null 值:
Mack null John ------〉null
Gisha null null------->null
有什么好办法么?
Thanks!
S*****0
发帖数: 538
2
select ISNULL(lastName, '') + ', ' + ISNULL(MiddleName, '') + ' '+ ISNULL(
LastName, '') from Table

【在 j****s 的大作中提到】
: 第一列为姓,第二列为中间名,第三列为名
: 要把这三列合起来做为一列,关键是第2列有null 值,有时第3列也有null值
: 怎么忽略这些null值?
: 需要:
: Mack null John ------〉Mack,John
: Gisha null null------->Gisha,
: Mathews M Peter----->Mathews, M Peter
: 用select lastName + ', ' + MiddleName + ' '+ LastName from Table
: 不行,handle不了null 值:
: Mack null John ------〉null

j****s
发帖数: 881
3
多谢,先吃个包子。
我回头试验一下。

【在 S*****0 的大作中提到】
: select ISNULL(lastName, '') + ', ' + ISNULL(MiddleName, '') + ' '+ ISNULL(
: LastName, '') from Table

w*****7
发帖数: 263
4
最好把那个逗号放到ISNULL里, i.e.; ISNULL(LASTNAME + ',', '')
g***l
发帖数: 18555
5
不要放逗号,CSV对逗号很敏感的,一般还是单独存FIRST MIDDLE LAST,输出的时候再
COMBINE
j****s
发帖数: 881
6
两位大佬接包子!
1 (共1页)
进入Database版参与讨论
相关主题
How to find all duplicate record in SQL?A simple question for SQL, seeking help
Questions on SQLHow to concatenate NULL value with a string in SQL Server?
where can I download SQL Sever? thanks (null)How to get other columns after UNION?
in DBMS, is NULL=NULL valid?吃了包子, 幹活了!
Re: How to concatenate NULL value with a string in SQL Server?not null in ms sql
新手问题求助请问sql 有条件性的select columns
Urgent SQL problem!SQL Query Question
SQL的一个愚蠢小问题A SQL problem
相关话题的讨论汇总
话题: null话题: lastname话题: isnull话题: gisha话题: john