I have a source code for my project which has lot of sql statement included in the sripts.But I am facing a problem with the ode as it throws an error as invalid object name whenever there is a sql transaction. I have found the reason as ..all sql
staments in the code are mentioned as selct * from tablename ...but the sql is considering it as invalid object name. if I change this value to select * from cp.tablename , it is working fine.
is it mandatory to give schema names also in sql statements? if it is mandatory then I have to make changes to lot of code...do we have any option where database considers schema name by default when we are running the statements with
simpple table name?. Please help e out
if you are executing the sql statements in the sql server then no need to give the schema name.
it will directly will accept the select* from table name, where as if you are trying from outsite like using a connection with the sql server and then writing the sql statement in an application in that case yes you need to give the schema name also
Please remember to click “Mark as Answer” on my response that helps you. This can be beneficial to other community members reading the thread.
see from the left side click on your data base name and then in the upper side there is one option new query and click on that than a new window will open and write the sql statement as
select* from your table name and then press f5
Please remember to click “Mark as Answer” on my response that helps you. This can be beneficial to other community members reading the thread.
harsharamoju
Member
4 Points
34 Posts
difference between select * from table to select * from scheaname.table
Mar 06, 2012 02:35 AM|LINK
Hi,
I have a source code for my project which has lot of sql statement included in the sripts.But I am facing a problem with the ode as it throws an error as invalid object name whenever there is a sql transaction. I have found the reason as ..all sql staments in the code are mentioned as selct * from tablename ...but the sql is considering it as invalid object name. if I change this value to select * from cp.tablename , it is working fine.
is it mandatory to give schema names also in sql statements? if it is mandatory then I have to make changes to lot of code...do we have any option where database considers schema name by default when we are running the statements with simpple table name?. Please help e out
naveenchandr...
Member
469 Points
232 Posts
Re: difference between select * from table to select * from scheaname.table
Mar 06, 2012 02:56 AM|LINK
hI
if you are executing the sql statements in the sql server then no need to give the schema name.
it will directly will accept the select* from table name, where as if you are trying from outsite like using a connection with the sql server and then writing the sql statement in an application in that case yes you need to give the schema name also
harsharamoju
Member
4 Points
34 Posts
Re: difference between select * from table to select * from scheaname.table
Mar 06, 2012 03:23 AM|LINK
hey I am getting same error in database also. if I dont give schema name it is not working.
I am using SQL Server 2008 R2.
naveenchandr...
Member
469 Points
232 Posts
Re: difference between select * from table to select * from scheaname.table
Mar 06, 2012 03:39 AM|LINK
see from the left side click on your data base name and then in the upper side there is one option new query and click on that than a new window will open and write the sql statement as
select* from your table name and then press f5
naveenchandr...
Member
469 Points
232 Posts
Re: difference between select * from table to select * from scheaname.table
Mar 06, 2012 03:39 AM|LINK
once you are done with that let me know the status