无法绑定多部分标识符 - SET子句

时间:2017-04-18 13:59:56

标签: sql sql-server join

我已经搜索过这个答案,但大多数似乎来自正在更新的表格,而不是来自获取信息的表格。

SET中的第一个B.DED1是抛出多部分标识符的B.DED1。然而,WHERE子句中的那个工作正常。

UPDATE #output
SET col1 = B.DED1
SELECT * 
FROM #output A  
 INNER JOIN TableName B
 ON A.Key = B.Key
WHERE B.DED1 = 'col1'

2 个答案:

答案 0 :(得分:2)

{
    "version": "1.0.0-*",
    "buildOptions": {
        "emitEntryPoint": true
    },

    "dependencies": {
            "Microsoft.EntityFrameworkCore.SqlServer": "1.1.1",
            "Microsoft.EntityFrameworkCore.Tools": "1.1.0",
            "Microsoft.NETCore.App": {
                "type": "platform",
                "version": "1.0.1"
            }
    },
    "tools": {
      ....
      "Microsoft.EntityFrameworkCore.Tools.DotNet": "1.1.0-preview4"  << Add respective version here
      ....
    },
    "frameworks": {
        "netcoreapp1.0": {
            "imports": "dnxcore50"
        }
    }
}

答案 1 :(得分:2)

将查询更改为:

UPDATE O SET col1 = B.DED1
FROM [#output] O  
INNER JOIN TableName B
ON O.Key = B.Key
WHERE B.DED1 = 'col1'