Correct ownership code reference in TSQL

  • Just Checking

    If I write code like this

    INSERT INTO Table1 VALUES( FieldA )

    SELECT FieldB FROM dbo.Table2

    The fact that I use "dbo." ON dbo.Table2 in code above is ok for the multiuser environment, when any number of users may action the procedure ?

     

  • using dbo in this context identifies the table owner. I.E. if you had two tables with the name table1 in your database, one owned by dbo and one owned by chris, doing an insert dbo.table1 would reference the one owned by the database owner, not the one owned by chris.

    It is a best practice to reference the table owner in a statement. You shouldn't have to worry about how many users reference the stored procedure (I assume that you are talking about putting the code into a sp).

  • ...'I assume that you are talking about putting the code into a sp). '..

    YES, and thanks for help

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply