SQL 服务器 - 当 运行 链接服务器 table 上的更新查询时,分隔标识符 [] 不起作用
SQL SERVER - delimited identifiers [] don't work when running an Update Query on a Linked Server table
所以我在SQL服务器中有一个链接服务器(访问mdb数据库)。我有一个叫做 XX2 Sectors
的 table(是的,我知道 table names/columns 中的白色 space 是一种不好的做法,但我没有在这种情况下控制它)。
当我 运行 以 SELECT 形式查询时
SELECT * FROM [Server_Name]...[XX2 Sectors]
它完全可以正常工作,但是当我运行正在对此 table 进行更新查询时,例如
UPDATE [Server_Name]...[XX2 Sectors] SET Column_Name = 'Variable' WHERE
Column_Name = 'whatever'`
I get an error: OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "Server_Name" returned message "The Microsoft Access database engine cannot find the input table or query 'XX2'. Make sure it exists and that its name is spelled correctly."
-> 所以基本上它在白色 space 点切断了 table 名称,[] 应该防止...但是如果我将 table 从 [=15 重命名=] 到 XX2_Sectors
-> 有效删除白色 space 然后更新查询工作正常。
有什么想法吗?我想我什么都试过了,但我现在不知所措...
谢谢。
尝试使用QUOTENAME.
Returns a Unicode string with the delimiters added to make the input
string a valid SQL Server delimited identifier.
QOUTENAME(XX2 Sectors)
而不是 [XX2 Sectors]
更新:所以答案是,由于某种原因,当您使用链接服务器时 SQL 服务器(我不知道是否有错误)但是如果您尝试更新已提交的文件 table在基于字段值的链接数据表(它是 Access)中,除非您也更新其他内容或选择其他条件,否则它将不起作用。例如:
UPDATE TABLE SET FIELD1 = Z WHERE FIELD1 = X
不会工作,但是
UPDATE TABLE SET FIELD1 = Z WHERE FIELD2 = X
或
UPDATE TABLE SET FIELD1 = Z, FILED2 = F WHERE FIELD1 = Y
或
UPDATE TABLE SET FIELD1 = Z, FIELD2 = FIELD2 WHERE FIELD1 = X
会很好用。
-------- 下面是旧答案 ------
3 小时后我找到了这个问题的解决方案,不幸的是这意味着没有解决方案,因为问题在我启动后自行解决...
所以我在SQL服务器中有一个链接服务器(访问mdb数据库)。我有一个叫做 XX2 Sectors
的 table(是的,我知道 table names/columns 中的白色 space 是一种不好的做法,但我没有在这种情况下控制它)。
当我 运行 以 SELECT 形式查询时
SELECT * FROM [Server_Name]...[XX2 Sectors]
它完全可以正常工作,但是当我运行正在对此 table 进行更新查询时,例如
UPDATE [Server_Name]...[XX2 Sectors] SET Column_Name = 'Variable' WHERE
Column_Name = 'whatever'`
I get an error: OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "Server_Name" returned message "The Microsoft Access database engine cannot find the input table or query 'XX2'. Make sure it exists and that its name is spelled correctly."
-> 所以基本上它在白色 space 点切断了 table 名称,[] 应该防止...但是如果我将 table 从 [=15 重命名=] 到 XX2_Sectors
-> 有效删除白色 space 然后更新查询工作正常。
有什么想法吗?我想我什么都试过了,但我现在不知所措...
谢谢。
尝试使用QUOTENAME.
Returns a Unicode string with the delimiters added to make the input string a valid SQL Server delimited identifier.
QOUTENAME(XX2 Sectors)
而不是 [XX2 Sectors]
更新:所以答案是,由于某种原因,当您使用链接服务器时 SQL 服务器(我不知道是否有错误)但是如果您尝试更新已提交的文件 table在基于字段值的链接数据表(它是 Access)中,除非您也更新其他内容或选择其他条件,否则它将不起作用。例如:
UPDATE TABLE SET FIELD1 = Z WHERE FIELD1 = X
不会工作,但是
UPDATE TABLE SET FIELD1 = Z WHERE FIELD2 = X
或
UPDATE TABLE SET FIELD1 = Z, FILED2 = F WHERE FIELD1 = Y
或
UPDATE TABLE SET FIELD1 = Z, FIELD2 = FIELD2 WHERE FIELD1 = X
会很好用。
-------- 下面是旧答案 ------
3 小时后我找到了这个问题的解决方案,不幸的是这意味着没有解决方案,因为问题在我启动后自行解决...