[dba-SQLServer] Invalid Object name, SQL 2012

Paul Hartland paul.hartland at googlemail.com
Wed Apr 3 12:46:43 CDT 2013


David,

Never had this happen in a stored procedure unless the table wasn't in the
database that I was creating the SP or I opened the query window and hadn't
got the correct database selected.  However I have only used upto version
2008, if you do find out what's happening then would like to know.

Paul


On 3 April 2013 18:14, David McAfee <davidmcafee at gmail.com> wrote:

> Have any of you come across this error?
>
> I am running a local instance of SQL 2012 on my box.
> I created a few tables and I am now creating a stored procedure.
>
> In the procedure, I get a red underline under one of the table names.
>
> When I mouse over the red underline, it displays: "Invalid object name
> 'tblTerritoryRsmJunct'"
>
> The select statement DOES work and return the correct values.
>
>
> SELECT
>      R.RegionDesc,
>      GSM.Fullname AS GSM,
>      RSM.Fullname AS RSM,
>      T.Territory,
>      T.TerrID AS TerritoryID
> FROM tblRegion R (NOLOCK)
>   INNER JOIN tblUser GSM (NOLOCK) ON R.GsmUserGuid = GSM.UserGuid
>   INNER JOIN tblTerritory T (NOLOCK) ON T.RegionID = R.RegionID
>   INNER JOIN (SELECT TerritoryID, MAX(entryDate) as MaxDate
>                       FROM tblTerritoryRsmJunct (NOLOCK)
>                       WHERE entryDate < @AsOfDate
>                       GROUP BY TerritoryID) AS RJ1 ON T.TerrID =
> RJ1.territoryid
>   INNER JOIN tblRouteSellerJunct AS RJ2 (NOLOCK)
>         ON RJ1.territoryID = RJ2.TerritoryID
>       AND RJ1.MaxDate = RJ2.entryDate
>   INNER JOIN tblUser RSM (NOLOCK) ON RSM.UserGuid = RJ2.RsmGuid
>
>
> I've even dragged in the table name from the Object explorer so it reads:
> [dbo].[tblRouteSellerJunct] but it still underlines it in red.
>
> The file name is 20 characters long. I've named tables with longer names
> before.
>
> Any ideas?
>
> Thanks,
> David
> _______________________________________________
> dba-SQLServer mailing list
> dba-SQLServer at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
> http://www.databaseadvisors.com
>
>


-- 
Paul Hartland
paul.hartland at googlemail.com


More information about the dba-SQLServer mailing list