Sunday, March 25, 2012

Create a New Database that doesn't resemble the model database

I am trying to create a database with none of the user-defined tables
contained in the model database. All I need, essentially, is an empty
database.
ThanksCREATE DATABASE <DBNAME>
"Er" wrote:

> I am trying to create a database with none of the user-defined tables
> contained in the model database. All I need, essentially, is an empty
> database.
> Thanks
>|||That will still copy model....
HTH. Ryan
"Omnibuzz" <Omnibuzz@.discussions.microsoft.com> wrote in message
news:C20ECC39-66AB-4145-8E94-7214286141C7@.microsoft.com...
> CREATE DATABASE <DBNAME>
>
> "Er" wrote:
>|||I don't think that addresses the OP's concern.
USE model;
GO
CREATE TABLE dbo.foo(bar INT);
GO
USE master;
GO
CREATE DATABASE blat;
GO
SELECT bar FROM blat.dbo.foo;
-- blat should not have a table called foo
-- but it does, because it existed in model
GO
DROP DATABASE blat;
GO
"Omnibuzz" <Omnibuzz@.discussions.microsoft.com> wrote in message
news:C20ECC39-66AB-4145-8E94-7214286141C7@.microsoft.com...
> CREATE DATABASE <DBNAME>
>
> "Er" wrote:
>|||I tried that, but it still adds all the tables and stored procedures that ar
e
available in the model database.
"Omnibuzz" wrote:
> CREATE DATABASE <DBNAME>
>
> "Er" wrote:
>|||There are only two ways to create a database:
1: CREATE DATABASE. This copies model
2: Attach or restore. You need a database to attach (possibly created on som
e other system) or
restore from.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Er" <Er@.discussions.microsoft.com> wrote in message
news:0DB33B84-0C77-4EDA-8A8D-785F8790E81D@.microsoft.com...
>I am trying to create a database with none of the user-defined tables
> contained in the model database. All I need, essentially, is an empty
> database.
> Thanks
>|||Can i ask what these user defined tables and SPs are ...?
Everytime you restart SQL Server , TEMPDB is re-created from a copy of
model, do you really want these user objects in TEMPDB. (Not that it matters
I suppose)
HTH. Ryan
"Er" <Er@.discussions.microsoft.com> wrote in message
news:C731211F-2ED9-4E7C-8CB9-BA8159B61D6A@.microsoft.com...
>I tried that, but it still adds all the tables and stored procedures that
>are
> available in the model database.
> "Omnibuzz" wrote:
>|||Oops.. sorry
"Ryan" wrote:

> That will still copy model....
> --
> HTH. Ryan
>
> "Omnibuzz" <Omnibuzz@.discussions.microsoft.com> wrote in message
> news:C20ECC39-66AB-4145-8E94-7214286141C7@.microsoft.com...
>
>|||Thanks, Tibor. In order to create the new empty database, (1) I created an
empty one on another system, (2) then copied the files to the system where I
wanted the database, (3) and reattached. Thanks, again.
-Er
"Tibor Karaszi" wrote:

> There are only two ways to create a database:
> 1: CREATE DATABASE. This copies model
> 2: Attach or restore. You need a database to attach (possibly created on s
ome other system) or
> restore from.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Er" <Er@.discussions.microsoft.com> wrote in message
> news:0DB33B84-0C77-4EDA-8A8D-785F8790E81D@.microsoft.com...
>|||Yes, that seems to be the easiest approach if your model is cluttered. Just
be careful with
collation. CREATE DATABASE will pick the collation from model, and if you di
d the CREATE DATABASE on
another instance, this database might not have the same collation as the oth
er database on the
destination instance.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Er" <Er@.discussions.microsoft.com> wrote in message
news:B23E5F75-68B3-4DBB-847E-1473EFB5FA67@.microsoft.com...
> Thanks, Tibor. In order to create the new empty database, (1) I created a
n
> empty one on another system, (2) then copied the files to the system where
I
> wanted the database, (3) and reattached. Thanks, again.
> -Er
> "Tibor Karaszi" wrote:
>

No comments:

Post a Comment