如果我做了以下陈述:
set @ParentMemberID = (select MemberID from tblMembers where ThirdPartyReference like @Branch_ThirdPartyReference)
没有结果。 @ParentMemberID的价值是什么?
由于
答案 0 :(得分:4)
只需使用SELECT
关键字
set @ParentMemberID = (select MemberID from tblMembers where ThirdPartyReference like @Branch_ThirdPartyReference)
--This will show you the value of @ParentMemberID
SELECT @ParentMemberID
答案 1 :(得分:2)
简化测试
declare @I int
set @I = 0
set @I = (select 1 where 0 = 1)
select @I
结果:
NULL
答案 2 :(得分:0)
可能在下面是查询您要查找的内容,请使用它,
SET @ParentMemberID = ISNULL((SELECT MemberID FROM tblMembers
WHERE ThirdPartyReference LIKE @Branch_ThirdPartyReference), 0)
SELECT @ParentMemberID
如果您不需要检查NULL
,那么下面的查询将完全适应:
SET @ParentMemberID = (SELECT MemberID FROM tblMembers
WHERE ThirdPartyReference LIKE @Branch_ThirdPartyReference)
SELECT @ParentMemberID