[英]Save the result of an SQL function to a variable within a select statement?
我試圖采用函數給出的值並將其保存到變量中,以檢查其是否不等於“ 0”。 經過廣泛的搜索,我找不到一種可行的方法。 可能嗎?
DECLARE @InspectionID AS VARCHAR(10)
SELECT
SYEL.UserComments AS 'UserComments',
SET @InspectionID = [Silco_Final].[dbo].[GetInspectionIDFromUserComments](SYEL.UserComments)
FROM SY_Edit_Log SYEL
WHERE SYEL.UserCode = 'broberts'
AND @InspectionID <> '0'
您不能直接在where子句中調用該函數嗎?
SELECT
SYEL.UserComments AS 'UserComments',
FROM SY_Edit_Log SYEL
WHERE SYEL.UserCode = 'broberts'
AND [Silco_Final].[dbo].[GetInspectionIDFromUserComments](SYEL.UserComments) <> '0'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.