在 SQL Server 2012 中,我想将concat
5 列分为 1,但在查询中它可以工作,但是当我放入视图时,它会给我一个错误,例如
消息 174,级别 15,状态 1,第 3 行
CONCAT 函数需要 2 个参数。
有什么问题,所以我可以修复它,因为它对于超过 1 列来说concat
是一个很好的功能,因为如果它为空,它们会使其为空..concatenate
代码:
SELECT
'Aan ' + A.Name AS 'Naam',
{ fn CONCAT('T.a.v. ', C.Salutation + ' ', C.FirstName + ' ', C.MiddleName + ' ', C.LastName) } AS 'T.a.v.',
ISNULL(ISNULL(A.Address1_Line2, A.Address1_Line1),
C.Address1_Line2) AS 'Adres',
ISNULL(A.Address1_PostalCode + ' ' + A.Address1_City, A.Address2_PostalCode + ' ' + A.Address2_City) AS 'Woonplaats',
'heer' + ' ' + ISNULL(C.MiddleName + ' ', N'') + ISNULL(C.LastName, N'') AS 'Aanhef'
FROM
dbo.Account AS A
FULL OUTER JOIN
dbo.Contact AS C ON A.Name = C.AccountIdName
WHERE
(C.Salutation = 'Dhr.') AND (A.Name IS NOT NULL) AND (A.StatusCode = 1)
AND (ISNULL(C.StatusCode, 1) = 1) OR (C.Salutation = 'dhr.') AND (A.Name IS NOT NULL) AND (A.StatusCode = 1) AND (ISNULL(C.StatusCode, 1) = 1)