Tuesday, February 14, 2012

creating database from sql file

I have an sql file that i am trying to open and execute to create a db with
the corresponding tables. When I execute this file the tables are created
but they are all under databases\system databases\master\tables. They are
not created in the system tables but all are created under the afore
mentioned location. What do I need to do the have the tables created under
another schema?In the script, add the following line before the CREATE TABLE statements:
USE <database> -- where <database> is the name of the newly created
database.
For more information, see
http://msdn2.microsoft.com/en-us/library/ms188366.aspx
Without the USE statement, all statements in the script are created in the
context of the current database, not the new database you created.
Regards,
Gail
--
Gail Erickson [MS]
SQL Server Documentation Team
This posting is provided "AS IS" with no warranties, and confers no rights
Download the latest version of Books Online from
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
"Tim" <gtu@.cablelynx.com> wrote in message
news:%2343NGAPZHHA.4772@.TK2MSFTNGP05.phx.gbl...
>I have an sql file that i am trying to open and execute to create a db
>with the corresponding tables. When I execute this file the tables are
>created but they are all under databases\system databases\master\tables.
>They are not created in the system tables but all are created under the
>afore mentioned location. What do I need to do the have the tables created
>under another schema?
>|||Also note that in SQL Server, a database and schema are not the same thing.
What version are you running?
Schemas were synonymous with object owners in SQL Server 2000, but in 2005
schemas are separate.
Both users names and schemas are within a database, and a SQL Server
instance can have many databases.
--
HTH
Kalen Delaney, SQL Server MVP
http://sqlblog.com
"Gail Erickson [MS]" <gaile@.online.microsoft.com> wrote in message
news:e7Uw4PPZHHA.2552@.TK2MSFTNGP06.phx.gbl...
> In the script, add the following line before the CREATE TABLE statements:
> USE <database> -- where <database> is the name of the newly created
> database.
> For more information, see
> http://msdn2.microsoft.com/en-us/library/ms188366.aspx
> Without the USE statement, all statements in the script are created in the
> context of the current database, not the new database you created.
> Regards,
> Gail
> --
> Gail Erickson [MS]
> SQL Server Documentation Team
> This posting is provided "AS IS" with no warranties, and confers no rights
> Download the latest version of Books Online from
> http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
>
> "Tim" <gtu@.cablelynx.com> wrote in message
> news:%2343NGAPZHHA.4772@.TK2MSFTNGP05.phx.gbl...
>>I have an sql file that i am trying to open and execute to create a db
>>with the corresponding tables. When I execute this file the tables are
>>created but they are all under databases\system databases\master\tables.
>>They are not created in the system tables but all are created under the
>>afore mentioned location. What do I need to do the have the tables
>>created under another schema?
>

No comments:

Post a Comment