Professional Web Applications Themes

using DatabaseName.dbo.TableName - Microsoft SQL / MS SQL Server

First, sorry for my bad english...I work hard to improve it I need to access a table in a different database Ex: I work on a table tableOne in my Database DbaseOne I need some info in tableTwo from the Database DBaseTwo Someone told me that my query who look like this: Select x1,x2 FROM tableOne t1 JOIN DBaseTwo.dbo.TableTwo t2 on t1.x1 = t2.x2 is not a good syntax. It is not recommended to use the "dbo" to access the table. Is it true? Is it a security question? How can I access this table?...

  1. #1

    Default using DatabaseName.dbo.TableName

    First, sorry for my bad english...I work hard to improve it

    I need to access a table in a different database

    Ex: I work on a table tableOne in my Database DbaseOne
    I need some info in tableTwo from the Database DBaseTwo

    Someone told me that my query who look like this:

    Select x1,x2
    FROM tableOne t1
    JOIN DBaseTwo.dbo.TableTwo t2 on t1.x1 = t2.x2

    is not a good syntax. It is not recommended to use the "dbo" to
    access the table. Is it true? Is it a security question? How can I
    access this table?
    Guy Tanguay Guest

  2. #2

    Default Re: using DatabaseName.dbo.TableName

    > is not a good syntax. It is not recommended to use the "dbo" to
    > access the table.
    Did they happen to mention why?

    If you are sure there is only one table named tablename, you can access it
    as

    databasename..tablename


    Aaron Bertrand - MVP Guest

  3. #3

    Default Re: using DatabaseName.dbo.TableName

    Using the ownername can provide a performance benefit, so it is usually a
    good thing. There is rarely a reason not to specify the owner.

    And just for completeness: even if there is only one table named tablename,
    if the owner is someone other the current user or dbo, you must qualify the
    tablename with the owner name.

    --
    HTH
    ----------------
    Kalen Delaney
    SQL Server MVP
    [url]www.SolidQualityLearning.com[/url]


    "Aaron Bertrand - MVP" <aaronTRASHaspfaq.com> wrote in message
    news:Oz1qg1yPDHA.704tk2msftngp13.phx.gbl...
    > > is not a good syntax. It is not recommended to use the "dbo" to
    > > access the table.
    >
    > Did they happen to mention why?
    >
    > If you are sure there is only one table named tablename, you can access it
    > as
    >
    > databasename..tablename
    >
    >

    Kalen Delaney Guest

  4. #4

    Default Re: using DatabaseName.dbo.TableName

    From a performance point of view, using dbo prefix (or any other owner name)
    is good, but using the database name prefix offers no advantage, and creates
    problems as you are hardcoding the database name.

    --
    HTH,
    Vyas, MVP (SQL Server)
    [url]http://vyaskn.tripod.com/[/url]
    What hardware is your SQL Server running on?
    [url]http://vyaskn.tripod.com/poll.htm[/url]




    "Guy Tanguay" <guy_tanguayhotmail.com> wrote in message
    news:3b53412a.0306300924.e15b7d8posting.google.co m...
    First, sorry for my bad english...I work hard to improve it

    I need to access a table in a different database

    Ex: I work on a table tableOne in my Database DbaseOne
    I need some info in tableTwo from the Database DBaseTwo

    Someone told me that my query who look like this:

    Select x1,x2
    FROM tableOne t1
    JOIN DBaseTwo.dbo.TableTwo t2 on t1.x1 = t2.x2

    is not a good syntax. It is not recommended to use the "dbo" to
    access the table. Is it true? Is it a security question? How can I
    access this table?


    Narayana Vyas Kondreddi Guest

Similar Threads

  1. sort tablename in sql table
    By sc in forum Coldfusion Database Access
    Replies: 4
    Last Post: September 27th, 12:52 AM
  2. CF requiring owner name prefix to tablename during query
    By AndyDC in forum Coldfusion Database Access
    Replies: 2
    Last Post: May 4th, 08:53 AM
  3. Replies: 0
    Last Post: December 18th, 09:18 AM
  4. ASP problem - Invalid object name 'dbo.tablename'
    By Tom Bynum in forum ASP Database
    Replies: 5
    Last Post: November 10th, 10:17 PM
  5. Drop table <tablename> failling
    By dotyet in forum IBM DB2
    Replies: 9
    Last Post: August 11th, 10:55 AM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139