SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2005
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Mssql and tables? Invalid object...

    Hi there,

    Firstly I'm a complete newbie when it comes to mssql. I have five MSSQL databases, In all of them except one I can easily do say...

    Code SQL:
    SELECT TOP 10 * FROM dt_Organizers

    However one of the new databases require me to do this:

    Code SQL:
    SELECT TOP 10 * FROM dbuser.dt_Organizers

    Note that all the tables in all databases have "dbuser" "dbamy" "dbyon" "dbmio" "dbcana" prefixes respectively, this never caused a problem before. Now if I use the query without doing dbuser.dt_Organizers it brings up:

    Warning: mssql_query() [function.mssql-query]: message: Invalid object name 'dt_Organizers'.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,248
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    are you using the USE command anywhere?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Zealot
    Join Date
    Oct 2005
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not at all. I'm using mssql_query function in php... does that help? ^^'

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,248
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    the USE command is intended to select the database for the commands which follow

    if you can't get FROM dt_Organizers to work, you're probably not in the dbuser database, which is why you have to say FROM dbuser.dt_Organizers
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,629
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    What I think is going on is the users who create the tables are making them in their own schema, so, if you are logged in as dbuser and you do SELECT * FROM dt_Organizers you are really doing SELECT * FROM dbuser.dt_Organizers. Check out the default schema property for the users -- should tell you alot.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •