我想運行這個查詢,但不工作。我收到一個錯誤。如何解決?:sql錯誤:轉換nvarchar轉換失敗
將nvarchar值'Jon Yang'轉換爲數據類型int時轉換失敗。
SQL
use adventureworks
go
select si.CustomerID,
'myField' =
CASE
When (Select Top 1 FirstName+ ' ' + LastName + ' ' + EmailPromotion From Person.Contact pc Where si.ContactID = pc.contactid) is not null Then
Cast((Select Top 1 FirstName+ ' ' + LastName + ' ' + EmailPromotion From Person.Contact pc Where si.ContactID = pc.contactid ) As varchar)
Else ''
END
from Sales.Individual si
where si.CustomerID=11000