unresolved reference to object [INFORMATION_SCHEMA].[TABLES]

前端 未结 3 1212
醉梦人生
醉梦人生 2020-11-28 23:34

I\'ve created a UDF that accesses the [INFORMATION_SCHEMA].[TABLES] view:

CREATE FUNCTION [dbo].[CountTables]
(
    @name sysname
)
RETURNS INT
         


        
相关标签:
3条回答
  • 2020-11-28 23:54

    Add a database reference to master:

    1. Under the project, right-click References.
    2. Select Add database reference....
    3. Select System database.
    4. Ensure master is selected.
    5. Press OK.

    Note that it might take a while for VS to update.

    0 讨论(0)
  • 2020-11-28 23:54

    In our project, we already have a reference to master, but we had this issue. Here was the error we got:

    SQL71502: Procedure: [Schema].[StoredProc1] has an unresolved reference to object [Schema].[Table1].[Property1].
    

    To resolve the reference error, on the table sql file, right click properties and verify the BuildSettings are set to Build.

    Changing it build fixed it.

    0 讨论(0)
  • 2020-11-29 00:06

    what Sam said is the best way for doing this.
    However, if you have a scenario that you need to deploy the dacpac from a machine that doesn't have that reference in that specific location, you may get into trouble. Another way is to open your .project file and make sure the following tag has the value of false for the build configuration you are trying to run.

    <TreatTSqlWarningsAsErrors>false</TreatTSqlWarningsAsErrors>
    

    This way you don't need to add a reference to your project.

    0 讨论(0)
提交回复
热议问题