Schemas in SQL

  • Hello,

    I'm created a new database which some tables in, I created two schema's called "Category" and "Devices"

    I created a new table and called it Category.ParentCategories I then saved the table and it now appears as

    dbo.Category.ParentCategories

    I want it to look like this

    Category.ParentCategories

    but when I created the Devices table "Device.DeviceBrand" and pressed saved it didn't append "dbo" in front of it?

  • Did you use the table designer in Mnagement Studio?

    If so, you'll need to change the schema in the properties window (F4).

    Or, even better, use the SQL command CREATE TABLE in a query window.



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • that's correct I used the management studio to create the table, I pressed f4 but I'm unsure what I'm looking for?

  • If you press F4 the properties window will open. There's a parameter "Schema" with ethe value "dbo". Change it to Category.

    Then create your table and save it as ParentCategories. Finally, delete the table in the wrong schema.

    Alternative:

    Right click the table in the Object Explorer window -> Script Table as -> Drop and Create -> new query editor window.

    Then change the table name in the CREATE TABLE section from [dbo].[Category.ParentCategories] to [Category].[ParentCategories].

    I'd prefer the 2nd option since this will acutally show you the SQL commands being executed.



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • Excellent it worked!

    thanks

Viewing 5 posts - 1 through 4 (of 4 total)

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