日期:2014-05-18 浏览次数:20640 次
if object_id('tb') is not null drop table tb go create table tb(col nvarchar(max)) go insert into tb select 'abc' union all select 'def' go select right('abc',0) --显示为空 select right('def',0) --显示为空 select col,right(col,0) from tb --显示为Null
if object_id('tb') is not null drop table tb go create table tb(col nvarchar(max)) go insert into tb select 'abc' union all select 'def' go select right('abc',0)--显示为空 (无列名) select right('def',0) --显示为空 (无列名) select col,right(col,0) from tb /* col (无列名) abc def */ 我这全为空,没出现null
------解决方案--------------------
楼主是什么环境,以下测试环境是没问题的,结果一致
环境:
Microsoft SQL Server 2008 (RTM) - 10.0.1600.22 (X64) Jul 9 2008 14:17:44 Copyright (c) 1988-2008 Microsoft Corporation Enterprise Evaluation Edition (64-bit) on Windows NT 6.1 <X64> (Build 7600: ) (VM)
------解决方案--------------------
declare @a varchar(10) set @a=N'abc' select right(@a,0) select right(convert(nvarchar(max),'def'),0 ---- (1 row(s) affected) ---------------------------------------------------------------------------------------------------------------- NULL (1 row(s) affected)