Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

INVALID OBJECT NAME Expand / Collapse
Author
Message
Posted Monday, October 1, 2012 6:04 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, July 29, 2014 1:56 PM
Points: 32, Visits: 184
Hello,

I have wrote one store proc. So, in the stored procedure, it is using one table which is in the different database. When I am trying to execute the stored proc it is giving me this error "INVALID OBJECT NAME". I have also given the permission to the stored proc.
Following is the sample stored proc:

create proc proc_name(inputs)
AS
BEGIN
select x.id,y.name
FROM dbo.X_name x inner join dbname.dbo.Y_name y ON x.is=y.id
END

ERROR: Invalid Object Name 'dbname.dbo.Y_name'

NOTE: I got this error when I altered the procedure. Before it was running properly.
Post #1366840
Posted Tuesday, October 2, 2012 2:51 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Tuesday, November 18, 2014 7:54 AM
Points: 317, Visits: 1,082
Is the other database on the same server?

What change did you make that stopped it working? Was it adding the reference to dbo.Y_name?
Post #1366906
Posted Tuesday, October 2, 2012 3:17 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, November 18, 2014 3:45 AM
Points: 2,873, Visits: 5,188
So looks like that dbname.dbo.Y_name is not accessible from connection you are trying to execute your procedures. Check the name spelling as well.


_____________________________________________
"The only true wisdom is in knowing you know nothing"
"O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!"
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
Post #1366918
Posted Tuesday, October 2, 2012 7:57 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, October 31, 2013 3:44 AM
Points: 314, Visits: 4,128
The error is almost certainly what it is.

I would just check and confirm the spelling, database and objects you are trying to access.
Post #1367052
Posted Tuesday, October 2, 2012 8:45 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 9:38 AM
Points: 6,861, Visits: 14,160
deepeshdhake (10/1/2012)
Hello,

I have wrote one store proc. So, in the stored procedure, it is using one table which is in the different database. When I am trying to execute the stored proc it is giving me this error "INVALID OBJECT NAME". I have also given the permission to the stored proc.
Following is the sample stored proc:

create proc proc_name(inputs)
AS
BEGIN
select x.id,y.name
FROM dbo.X_name x inner join dbname.dbo.Y_name y ON x.is=y.id
END

ERROR: Invalid Object Name 'dbname.dbo.Y_name'

NOTE: I got this error when I altered the procedure. Before it was running properly.


Run these two queries and post back the results.

Query 1
select TOP 10 x.id,y.name
FROM dbo.X_name x inner join dbname.dbo.Y_name y ON x.is=y.id

Query 2
select TOP 10 * FROM dbname.dbo.Y_name



“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Exploring Recursive CTEs by Example Dwain Camps
Post #1367086
Posted Wednesday, October 3, 2012 4:57 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, February 27, 2014 6:05 AM
Points: 43, Visits: 162
HI,

I have created a similar query to yours and it works fine for me. So the problem must be with the syntax. Kindly check it once.

Create Procedure Test(@SCAC Varchar(50))
AS
Begin
Select SCAC, emailAddress
From OC_CARR_BALANCEDUE Balance join OC_User.dbo.portaValues code
on code.codeValue = balance.SCAC and Balance.SCAC = @SCAC

END
Post #1367555
Posted Friday, October 5, 2012 1:48 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 6:37 AM
Points: 1,938, Visits: 2,374
Hi,

I run the similar query and I didnt get the any error.

create procedure abc as
select x.id,y.name1 from name1 x
inner join Practice.dbo.name1 y ON x.id=y.ID

Command executed successfully

EXEC abc
Result- it returns the matching rows.

Please try to run the query as select * from db_name.dbo.tablename ans check if it is returnug desired result or any error.



_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1368861
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse