数据类型nvarchar和nvarchar在'&'中不兼容。操作者

时间:2014-09-16 14:20:48

标签: sql sql-server-2008-r2 add nvarchar

尝试将dosrorder.nummer添加到Dossier.nummer但不幸的是SQL告诉我

数据类型nvarchar和nvarchar在'&'中不兼容。操作

SELECT     
    Dossier.OrderType, Dossier.Nummer AS OrderNummer, 
    DosrOrder.Nummer, Dossier.Nummer & [.] & DosrOrder.Nummer AS Totaal
FROM         
    Dossier 
INNER JOIN
    DosrOrder ON Dossier.ID = DosrOrder.DosrID

1 个答案:

答案 0 :(得分:3)

您使用错误的方法在SQL Server中进行连接。正确的方法是使用+(假设您的列为NVARCHAR):

SELECT  D.OrderType, 
        D.Nummer AS OrderNummer, 
        DO.Nummer, 
        D.Nummer + N'.' + DO.Nummer AS Totaal
FROM Dossier AS D
INNER JOIN DosrOrder AS DO
    ON D.ID = DO.DosrID