Results 1 to 4 of 4

Thread: [RESOLVED] [dbo] vs [erp] tables

  1. #1

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Resolved [RESOLVED] [dbo] vs [erp] tables

    Hi all,
    This is a question out of curiosity mostly, but it does have a need for what I am trying to do.

    I have a customer that uses Epicor for their ERP system. All of the data for the ERP in on an SQL Server and all of the tables in the ERP database are prefixed with "[erp]". So when I reference one of the table in c# the sql would look like this

    Code:
    SELECT * FROM [erp].[tableName]
    However if I were to create a new table on the server (in a different database) the table uses the "[dbo]" prefix.

    What is the difference with the [erp] and [dbo] prefixes and why does SQL server do this?

    I have been tasked with creating a relatively large app that will pull data from 2 or 3 ERP tables and I will need to create a number of new tables in a different database on the same server. When I do work for this customer, I normally would use their VPN to RDP into a development machine on their network which allows direct access to their database. Because of the size of this project, we I've assigned a second developer to work on it. To allow parallel work on the app, I want to recreate 2 or 3 of the customers' ERP tables on our local SQL Server to do a bulk of the development locally, but when I create the tables locally, they have a [dbo] prefix instead of the [erp] prefix.

    Any insight would be appreciated.
    Thank
    Kevin
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  2. #2
    Fanatic Member
    Join Date
    Jul 2022
    Location
    Buford, Ga USA
    Posts
    631

  3. #3
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    6,182

    Re: [dbo] vs [erp] tables

    [erp] and [dbo] are different schemas. Think of this as namespace in .Net, a logical separation of db object that object names accross different schemas do not collide. Another possible use of db schemas is permission assignment -- a user can have read/write permissions on [erp] schema but read-only on [dbo] or no access at all.

    When creating and accessing objects in your db (tables, views, sps, etc.) you can prefix object name with optional schema name like CREATE TABLE erp.MyTable or CREATE PROC dbo.usp_MyProc

    When schema is omitted from object names query planner uses default schema for the current db user which is dbo for sa login (server administrators) and this default resolution might fail for non-admins and/or lead to permission problems.

    cheers,
    </wqw>

  4. #4

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: [dbo] vs [erp] tables

    Quote Originally Posted by wqweto View Post
    [erp] and [dbo] are different schemas....
    cheers,
    </wqw>
    Thank you for that.
    For others who may stumble on this, if the schema does not exist, you cannot create a table in it. You can create schemas using this,
    CREATE SCHEMA schemaName
    kevin
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

Posting Permissions

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



Click Here to Expand Forum to Full Width