467,138 Members | 1,334 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,138 developers. It's quick & easy.

How to mit the Schema name when referrring to Tables?

Hi guys, please help.

What I did is :
Step1. create a Database named [Test], it's default owner is [sa]
Step2. create a User in Database [Test] named [kimliuTest], which maps
to the Login [kkhad\kimliu] on this Database Server, it's a windows
domain user.
Step3. create a Schema in Database [Test] named [schTest], whose Schema
Owner is User [kimliuTest]
Step4. created two tables: [dbo].[t1] and [schTest].[t2]
Step5. run the script

ALTER USER kimliuTest WITH DEFAULT_SCHEMA = schTest

to set the default schema.

Now my problem is, when I try to run

select * from schTest.t2

, everything is OK, but if I run

select * from t2

the error message says:

Msg 208, Level 16, State 1, Line 1
Invalid object name 't2'.

why? I'm loggin in with my [kkhad\kimliu] windows domain id , Active
Monitor also shows that. but the command does not work?

Yeah, it's a good habit to write the full name of the Table with Schema
name as prefix, however, we did our development in SQL 2000 and trying
to upgrade to SQL2005, so trying to avoid scanning codes and inserting
in thousand of places.

How could we omit the Schema name when referrring to Tables? Thanks.
ps. I posted in another topic days ago, but nobody is replying, when I
tried to bring it forward by replying myself, it failed. please help me
, thanks!

Jan 9 '06 #1
  • viewed: 1268
Share:

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by N. Shamsundar | last post: by
7 posts views Thread by Robert Stearns | last post: by
16 posts views Thread by Bob Stearns | last post: by
2 posts views Thread by David++ | last post: by
3 posts views Thread by karanbikash@gmail.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.