I am trying to run this query but myfield does not contain the full email address, lastname ,phone and email promotion values? It looks like there is a limit on the length of myField?
sql statement:
use adventureworks
go
select si.CustomerID,
'myField' =
CASE
When (Select Top 1 FirstName+ ' ' + MiddleName + ' '+ Phone + ' ' + EmailAddress +' '+ LastName + ' ' + Phone + ' ' + cast(EmailPromotion as varchar) From Person.Contact pc Where si.ContactID = pc.contactid ) is not null Then
Cast((Select Top 1 FirstName+ ' ' + MiddleName + ' ' + Phone + ' ' +EmailAddress +' '+ LastName + ' ' + Phone + ' ' + cast(EmailPromotion as varchar) From Person.Contact pc Where si.ContactID = pc.contactid ) As varchar)
Else ''
END
from Sales.Individual si
where si.CustomerID=11000
For
varchar[(n)]:So explicitly specify a suitably long length in your
CAST, e.g.varchar(256)Ref.