VS 2010 中的数据库项目无法使用 sys.syscolumns 构建/验证脚本
我正在尝试使用新创建的脚本构建一个数据库项目,其中包含对 sys.syscolumns 和 sys.sysobjects 的引用。
该错误表明
Error 12 SQL03006:
View: [dbo].[UtilityTableColumnView] has an unresolved reference to
object [sys].[syscolumns]. ...\Schemas\dbo\Views\UtilityTableColumnView.view.sql
VS 2010 在本地 SQL Server 2008 Developer Edition 上的管理员帐户下运行。
该脚本是
CREATE VIEW [dbo].[UtilityTableColumnView] AS
SELECT
O.[id] AS TableSystemId,
O.[name] AS TableName,
C.[id] AS ColumnSystemId,
C.[name] AS ColumnName,
C.xtype AS ColumnSystemXType,
C.typestat AS ColumnSystemTypeStat,
C.xusertype AS ColumnSystemXUserType,
C.[length] AS ColumnSystemLength,
C.xprec AS ColumnSystemXPrec,
C.colid AS SystemColId,
C.colorder AS SystemColumnOrder
FROM
sys.syscolumns C INNER JOIN
sys.sysobjects O ON O.[id] = C.[id]
WHERE
O.xtype = 'U'
任何想法如何解决这个问题?
I'm trying to build a database project with just newly created script containing references to sys.syscolumns and sys.sysobjects.
The error says
Error 12 SQL03006:
View: [dbo].[UtilityTableColumnView] has an unresolved reference to
object [sys].[syscolumns]. ...\Schemas\dbo\Views\UtilityTableColumnView.view.sql
VS 2010 is running under Administrator account who is admin on local SQL server 2008 Developer edition.
The script is
CREATE VIEW [dbo].[UtilityTableColumnView] AS
SELECT
O.[id] AS TableSystemId,
O.[name] AS TableName,
C.[id] AS ColumnSystemId,
C.[name] AS ColumnName,
C.xtype AS ColumnSystemXType,
C.typestat AS ColumnSystemTypeStat,
C.xusertype AS ColumnSystemXUserType,
C.[length] AS ColumnSystemLength,
C.xprec AS ColumnSystemXPrec,
C.colid AS SystemColId,
C.colorder AS SystemColumnOrder
FROM
sys.syscolumns C INNER JOIN
sys.sysobjects O ON O.[id] = C.[id]
WHERE
O.xtype = 'U'
Any ideas how to resolve this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

您必须将系统数据库目录添加到您的项目中。将位于 C:\Program Files (x86)\Microsoft Visual Studio 10.0\VSTSDB\Extensions\SqlServer\2008\DBSchemas 中的架构文件的引用添加到数据库项目引用中。
You have to add the system database catalog to your project. Add a reference to the schema file located in C:\Program Files (x86)\Microsoft Visual Studio 10.0\VSTSDB\Extensions\SqlServer\2008\DBSchemas to your db project references.