SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


INVALID OBJECT NAME


INVALID OBJECT NAME

Author
Message
deepeshdhake
deepeshdhake
SSC Rookie
SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)

Group: General Forum Members
Points: 36 Visits: 188
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.
laurie-789651
laurie-789651
SSChasing Mays
SSChasing Mays (616 reputation)SSChasing Mays (616 reputation)SSChasing Mays (616 reputation)SSChasing Mays (616 reputation)SSChasing Mays (616 reputation)SSChasing Mays (616 reputation)SSChasing Mays (616 reputation)SSChasing Mays (616 reputation)

Group: General Forum Members
Points: 616 Visits: 1272
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?
Eugene Elutin
Eugene Elutin
SSCarpal Tunnel
SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)

Group: General Forum Members
Points: 4990 Visits: 5478
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!":-D
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
OTF
OTF
Mr or Mrs. 500
Mr or Mrs. 500 (500 reputation)Mr or Mrs. 500 (500 reputation)Mr or Mrs. 500 (500 reputation)Mr or Mrs. 500 (500 reputation)Mr or Mrs. 500 (500 reputation)Mr or Mrs. 500 (500 reputation)Mr or Mrs. 500 (500 reputation)Mr or Mrs. 500 (500 reputation)

Group: General Forum Members
Points: 500 Visits: 4128
The error is almost certainly what it is.

I would just check and confirm the spelling, database and objects you are trying to access.
ChrisM@Work
ChrisM@Work
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16262 Visits: 19551
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
ard5karthick
ard5karthick
SSC-Enthusiastic
SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)SSC-Enthusiastic (105 reputation)

Group: General Forum Members
Points: 105 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
kapil_kk
kapil_kk
Hall of Fame
Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)

Group: General Forum Members
Points: 3091 Visits: 2766
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/
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search