什么是“多部分标识符",为什么不能绑定? [英] What is a 'multi-part identifier' and why can't it be bound?

查看:18
本文介绍了什么是“多部分标识符",为什么不能绑定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试根据另一个表更新表时,我不断收到这些错误.我最终重写了查询,更改了连接顺序,更改了一些分组,然后它最终起作用了,但我不太明白.

I continually get these errors when I try to update tables based on another table. I end up rewriting the query, change the order of joins, change some groupings and then it eventually works, but I just don't quite get it.

什么是多部分标识符"?
何时无法绑定多部分标识符"?
无论如何,它与什么绑定?
什么情况下会出现这个错误?
预防它的最佳方法是什么?

What is a 'multi-part identifier'?
When is a 'multi-part identifier' not able to be bound?
What is it being bound to anyway?
In what cases will this error occur?
What are the best ways to prevent it?

来自 SQL Server 2005 的具体错误是:

The specific error from SQL Server 2005 is:

无法绑定多部分标识符...".

The multi-part identifier "..." could not be bound.

这是一个例子:

UPDATE  [test].[dbo].[CompanyDetail]

SET Mnemonic = [dbBWKMigration].[dbo].[Company].[MNEMONIC], 
               [Company Code] = [dbBWKMigration].[dbo].[Company].[COMPANYCODE]

WHERE [Company Name] = **[dbBWKMigration].[dbo].[Company].[COMPANYNAME]**

实际错误:

Msg 4104, Level 16, State 1, Line 3 多部分标识符无法绑定dbBWKMigration.dbo.Company.COMPANYNAME".

Msg 4104, Level 16, State 1, Line 3 The multi-part identifier "dbBWKMigration.dbo.Company.COMPANYNAME" could not be bound.

推荐答案

多部分标识符是对包含多个部分的字段或表的任何描述 - 例如 MyTable.SomeRow - 如果无法绑定,则意味着存在某些内容错了 - 你有一个简单的错字,或者表和列之间的混淆.它也可能是由于在表或字段名称中使用保留字而不是用 [] 包围它们引起的.也可能是因为目标表中未包含所有必需的列.

A multipart identifier is any description of a field or table that contains multiple parts - for instance MyTable.SomeRow - if it can't be bound that means there's something wrong with it - either you've got a simple typo, or a confusion between table and column. It can also be caused by using reserved words in your table or field names and not surrounding them with []. It can also be caused by not including all of the required columns in the target table.

redgate sql prompt 之类的东西非常适合避免手动操作输入这些(它甚至会根据外键自动完成连接),但不是免费的.SQL Server 2008 支持开箱即用的智能感知,尽管它不如 redgate 版本完整.

Something like redgate sql prompt is brilliant for avoiding having to manually type these (it even auto-completes joins based on foreign keys), but isn't free. SQL server 2008 supports intellisense out of the box, although it isn't quite as complete as the redgate version.

这篇关于什么是“多部分标识符",为什么不能绑定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆