I have below query in which i am inserting into the temporary table and when i try to run the query sql is throwing binary or string data would be truncated. But actually my data is in the range of defined nvarchar(400) for column PhoneModel.
CREATE TABLE #orders
(
quoteHeaderId INT,
PhoneModel nvarchar(400)
)
INSERT INTO #orders(quoteHeaderId, PhoneModel)
SELECT qh.QuoteHeaderId,
(Select ph.ModelName + ','
FROM t_handsetQuote h2
INNER JOIN t_PhoneAudit t1 on t1.PhoneAuditId = h2.QuotePhoneAuditId
INNER JOIN t_phoneModel ph on t1.phoneModelid = ph.phoneModelid
where qh.QuoteHeaderId = h2.QuoteHeaderId
FOR XML PATH('')
) AS PhoneModel
FROM t_QuoteHeader qh
INNER JOIN t_handsetQuote h on qh.QuoteHeaderId = h.QuoteHeaderId
INNER JOIN t_CustomerAdditionalInformation ch on qh.CustomerId = ch.CustomerId
and keyName ='SendUpdatesByEmail' AND ch.value = 'yes'