Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
while running a query like
SQL
select * from table_name


it throws error
SQL
Invalid object name 'table_name'.

but when running the query like

SQL
select * from rlc.table_name

rlc is my db name its running correctly

plz someone suggess how to solve the problem
Posted

Looks like the table is created in a schema called rlc. If this is true, you have to define the schema name for the table (as you did in second example) or create a synonym for it.

Consider the following:
SQL
create schema testschema;

create table testschema.sometable (
   col1 int
);

select * from sometable; // FAILS

select * from testschema.sometable; //OK

create synonym sometable for testschema.sometable;

select * from sometable; //OK

select * from testschema.sometable; //OK
 
Share this answer
 
Comments
Miss Maheshwari 29-Dec-12 11:50am    
Thank you very much....yes...:)
i was in trouble from last week...thank you once again
Wendelius 29-Dec-12 11:54am    
You're welcome :)
ridoy 29-Dec-12 12:42pm    
+5
Wendelius 29-Dec-12 15:00pm    
Thanks :D
Sergey Alexandrovich Kryukov 29-Dec-12 21:59pm    
To the point, nice and simple explanation, a 5.
—SA
there are 2 possibilities for your problem

1. your database name may not be rcl on target , by default it may be master db or some other db
2. your table name may be in rcl schema. if your table is in other than dbo schema then you have to specify schema name. then only your query will be execute
 
Share this answer
 
Check your connection string - you probably haven't set the "Initial Catalog" value.
 
Share this answer
 
Comments
Miss Maheshwari 29-Dec-12 11:25am    
i am running the query from sql server query analyzer
esto se debe a que nos has escogido la base de datos donde lo muestro a continuación

master
rcl


Rough translation(?):

This is because you have not chosen the database correctly. Change as below
master
rcl
 
Share this answer
 
v2
Comments
Wendelius 29-Dec-12 11:42am    
Because of site policy, only English posts are accepted.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900