0
這是我的查詢:SQL選擇與Len - 轉換失敗?
SELECT at.AssetTag,
dp.Custodian,
CASE WHEN PATINDEX('%_%', dp.Custodian) = '0'
THEN dp.Custodian
ELSE RIGHT(LTRIM(RTRIM(dp.Custodian)),LEN(LTRIM(RTRIM(dp.Custodian)) - PATINDEX('%_%', dp.Custodian))) END AS FirstName,
CASE WHEN PATINDEX('%_%', dp.Custodian) = '0'
THEN ''
ELSE LEFT(dp.Custodian, PATINDEX('%_%', dp.Custodian)-1) END AS LastName, RIGHT(at.Assettag,3) AS MediaTypeSuffix
FROM tblAssetTracking at (NOLOCK)
INNER JOIN tblDiscoveryProcessing dp (NOLOCK) ON dp.FKAsset = at.ID
WHERE dp.Custodian Is Not Null
當我運行它,我得到一個錯誤的「nvarchar的值‘XXX’轉換爲數據類型爲int時轉換失敗」(xxx是實際值我不得不更換)。任何人都可以幫忙嗎? PS。我希望這個聲明能夠進入代碼塊。顯然,我不明白如何正確粘貼代碼。
謝謝!