Invalid Object Name

  • I have created the following function:

    CREATE FUNCTION [dbo].[DailyActivity]

    (

    )

    RETURNS @SalesData TABLE

    (

    ...columns

    )

    AS

    BEGIN

    ...statements

    RETURN

    END

    GO

    When I try to select from the function i.e SELECT * FROM dbo.DailyActivity() the function name is underlined in red and the hover message is "Invalid Object Name". However, the statement still executes and the data is returned?! I have also tried SELECT * FROM dbo.DailyActivity but the same occurs.

    I am using SQL Server 2008 R2.

  • In SSMS, select Edit | Intellisense | Refresh Local Cache

    Apparently, you built the function after opening the query window.

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • Thanks Wayne, I didn't know about that IntelliSense cache 🙂

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply