大家好我在sql server 2008工作,我不知道在这里我写了 脚本我从两列获取数据,我有两个路径来调用数据 我想知道,如果在那两列中一列是空的或空白我想检查 在其他路径这里写了一些错误的你可以帮助
Tahnks in Advance
DECLARE @xmltbl TABLE (ID INT, XmlData XML)
INSERT INTO @xmltbl(ID, XmlData)
VALUES((select Id from News where sId=129),(select content from News where sId=129));
;WITH XMLNAMESPACES (DEFAULT 'http:microsoft.com')
SELECT ID, C.value('(.)[1]', 'varchar(1000)') DataText FROM @xmltbl
CROSS APPLY
XmlData.nodes('/BreezyCalc/Graph/point') n (C)
select DataText from @xmltbl
if (DataText ="")
BEGIN
INSERT INTO @xmltbl(ID, XmlData)
VALUES((select Id from News where sId=129),(select content from News where sId=129));
;WITH XMLNAMESPACES (DEFAULT 'http://schemas.microsoft.com/winfx/2006/xaml/presentation')
SELECT ID, C.value('(.)[1]', 'varchar(1000)') DataText FROM @xmltbl
CROSS APPLY
XmlData.nodes('BreezyCalc/Graph/point/@Text') n (C)
select DataText from @xmltbl
END
结果应该是
ID DataText
-------------------
129 |lines added
答案 0 :(得分:0)
DECLARE @Datatext as varchar(200)=''
,IDParameter as Int = 129
SET @Datatext= (select top 1 XMLData from @xmltbl where ID=@IDParameter)
if ISNULL(@DataText,'') =''
BEGIN
some code here
END
ELSE IF (Some Other Condition)
BEGIN
some code here
END
如果它是一个逻辑流程,你可以省略IF (Some Other Condition)
。