Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 2005 SQL Server 2005:如何检查空字符串_Sql Server 2005 - Fatal编程技术网

Sql server 2005 SQL Server 2005:如何检查空字符串

Sql server 2005 SQL Server 2005:如何检查空字符串,sql-server-2005,Sql Server 2005,我有一个过程,如果MobileAreaCode+Mobile不为null,则返回MobileAreaCode+Mobile 我只是想增加对空字符串的支持,我也尝试过(没有空字符串的句柄,它可以工作) ALTER PROCEDURE PROC\u NAME @识别整数 作为 开始 挑选 MobileAreacCode不为NULL或Mobile不为NULL时的情况 或MobileAreaCode“”或Mobile“” 然后 MobileAreaCode+Mobile 结束 从…起 表名称 哪里 id

我有一个过程,如果MobileAreaCode+Mobile不为null,则返回MobileAreaCode+Mobile 我只是想增加对空字符串的支持,我也尝试过(没有空字符串的句柄,它可以工作)

ALTER PROCEDURE PROC\u NAME
@识别整数
作为
开始
挑选
MobileAreacCode不为NULL或Mobile不为NULL时的情况
或MobileAreaCode“”或Mobile“”
然后
MobileAreaCode+Mobile
结束
从…起
表名称
哪里
id=123456789
结束
去
这不起作用,并导致以下错误:

关键字“FROM”附近的语法不正确

你可以用


不起作用,对于上面的答案,我得到的结果是Mobile=''和MobileAreaCode=555->555。(现在都是nvarchar(50)check。或者在我的代码中改为andi use execute scalar,当我运行该过程时,它返回{}作为null值(null值是当我调用该过程时,但列中的值不正确。我如何在我的代码中的if语句中包含它’类似if(ExecuteScalar(“Proc_name)!=null’)我使用.net作为语言我找到了答案,我只需打电话“ToString”并询问它是否正确
ALTER PROCEDURE PROC_NAME
    @Identification INT
AS
BEGIN
    SELECT 
    CASE WHEN MobileAreaCode is NOT NULL OR Mobile is NOT NULL 
OR MobileAreaCode<>'' OR Mobile<>''
    THEN
        MobileAreaCode+Mobile
    END
    FROM 
        TABLE_NAME
    WHERE 
        id = 123456789
END
GO
ALTER PROCEDURE PROC_NAME
@Identification INT
AS
BEGIN
SELECT 
CASE WHEN (MobileAreaCode is NOT NULL) AND (Mobile is NOT NULL) 
AND (len(MobileAreaCode)>0) AND (len(Mobile)>0)
THEN
    MobileAreaCode+Mobile
END
FROM 
    TABLE_NAME
WHERE 
    id = 123456789
END
GO
select nullif(MobileAreaCode, '')+nullif(Mobile, '') as MobileAreaCodeMobile
from YourTable