none
creating a new database in SQL 2005

    Question

  • I have been trying to create a new database in SQL 2005 and each time I do so, it brings tables in from other locations.  Any suggestions?  Dave
    Sunday, October 22, 2006 7:59 PM

Answers

  • 
    What tables?  Have you checked the Model database?  That's the place where that would most likely come from...
     

    --
    Adam Machanic
    Pro SQL Server 2005, available now
    http://www..apress.com/book/bookDisplay.html?bID=457
    --
     
     
    I have been trying to create a new database in SQL 2005 and each time I do so, it brings tables in from other locations. Any suggestions? Dave
    Sunday, October 22, 2006 9:34 PM
  • 
    The Model database is one of the SQL Server system databases.  It's used as the basis for creation of any new database on the server -- if you have a table (or any other object) in Model, it will be created in a new database as well.  You can find it if you navigate under the Databases tab, to the System Databases.
     

    --
    Adam Machanic
    Pro SQL Server 2005, available now
    http://www..apress.com/book/bookDisplay.html?bID=457
    --
     
     
    It was pulling in tables from another database under the "database" tab under the server. Everytime I create a new database, somehow it pulls the tables from another data base, (no matter how many new databases I create) The tables are always the same. I guess I am at a loss as to where the Model database is. Thanks for the response. This is driving me crazy. The instructor sent me a message asking me if I had created it in a new "shell". Guess I do not know where this "shell" is located. Sorry to ask such elementry questions. I can not find anything anywhere, it seems, to help me with this one. Thanks again in advance if you can help me here and for replying earlier. Dave
    Monday, October 23, 2006 5:30 AM
  • Hi Dave,

    The model database that Adam referred to will be under "System Databases" in SQL Server Management Studio. 

    The model database acts as a template from which all new databases are based upon, so if you create a new DB and the model db on that server has a bunch of tables (or other objects), these will be created in the new DB as well.

    If you are created the database with the FOR ATTACH clause, then the new database is not being created from scratch, but rather it is being created by attaching exising data files that will in turn contain db objects such as tables etc. 

    Can you tell us how you're trying to create the db?

    Cheers,

    Rob

    Monday, October 23, 2006 5:39 AM

All replies

  • 
    What tables?  Have you checked the Model database?  That's the place where that would most likely come from...
     

    --
    Adam Machanic
    Pro SQL Server 2005, available now
    http://www..apress.com/book/bookDisplay.html?bID=457
    --
     
     
    I have been trying to create a new database in SQL 2005 and each time I do so, it brings tables in from other locations. Any suggestions? Dave
    Sunday, October 22, 2006 9:34 PM
  • It was pulling in tables from another database under the "database" tab under the server.  Everytime I create a new database, somehow it pulls the tables from another data base, (no matter how many new databases I create) The tables are always the same.  I guess I am at a loss as to where the Model database is.  Thanks for the response.  This is driving me crazy.  The instructor sent me a message asking me if I had created it in a new "shell".  Guess I do not know where this "shell" is located.  Sorry to ask such elementry questions.  I can not find anything anywhere, it seems, to help me with this one.  Thanks again in advance if you can help me here and for replying earlier.  Dave
    Monday, October 23, 2006 4:44 AM
  • 
    The Model database is one of the SQL Server system databases.  It's used as the basis for creation of any new database on the server -- if you have a table (or any other object) in Model, it will be created in a new database as well.  You can find it if you navigate under the Databases tab, to the System Databases.
     

    --
    Adam Machanic
    Pro SQL Server 2005, available now
    http://www..apress.com/book/bookDisplay.html?bID=457
    --
     
     
    It was pulling in tables from another database under the "database" tab under the server. Everytime I create a new database, somehow it pulls the tables from another data base, (no matter how many new databases I create) The tables are always the same. I guess I am at a loss as to where the Model database is. Thanks for the response. This is driving me crazy. The instructor sent me a message asking me if I had created it in a new "shell". Guess I do not know where this "shell" is located. Sorry to ask such elementry questions. I can not find anything anywhere, it seems, to help me with this one. Thanks again in advance if you can help me here and for replying earlier. Dave
    Monday, October 23, 2006 5:30 AM
  • Hi Dave,

    The model database that Adam referred to will be under "System Databases" in SQL Server Management Studio. 

    The model database acts as a template from which all new databases are based upon, so if you create a new DB and the model db on that server has a bunch of tables (or other objects), these will be created in the new DB as well.

    If you are created the database with the FOR ATTACH clause, then the new database is not being created from scratch, but rather it is being created by attaching exising data files that will in turn contain db objects such as tables etc. 

    Can you tell us how you're trying to create the db?

    Cheers,

    Rob

    Monday, October 23, 2006 5:39 AM
  • I had created the database by right clicking on Databases and selecting new database.  I did look at the model and somehow it had been populated with the information from a database the instructor had provided for us earlier, that is I had connected it to the database.  Not sure how the tables got in the model though unless there was an SQL statement that pointed it that way.  Thanks for the advice.  Dave
    Thursday, October 26, 2006 5:02 AM
  • Also, thanks to all you who helped me.  I also just used the Create Database command in SQL to try to create a database with out using the automatic method (right clicking on database) however it also brought over the tables.  Dave
    Thursday, October 26, 2006 5:06 AM