我正在尝试使用新创建的脚本构建一个数据库项目,该脚本包含对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'
有任何想法如何解决此问题?
答案 0 :(得分:3)
您必须将系统数据库目录添加到项目中。将对位于C:\ Program Files(x86)\ Microsoft Visual Studio 10.0 \ VSTSDB \ Extensions \ SqlServer \ 2008 \ DBSchemas中的模式文件的引用添加到db项目引用中。