Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CREATE DATABASE ends up cloning an old database

I have run into something quite odd, i haven't had this issue before, or maybe i'm missing something here.

In SQL Server Management Studio 2012 i am trying to run a Query to create a new database but it ends up cloning an old database, the code i'm using is:

CREATE DATABASE SEC_SSG_INOUT;
GO

USE SEC_SSG_INOUT;
GO

The database gets created with the correct name but it contains the same tables and stored procedures as an old database called SEC_SSG, but with empty data.

What is going on here?

like image 233
ArturoAP Avatar asked May 05 '16 21:05

ArturoAP


People also ask

How do I create a new database from an existing database?

To create a development database In SQL Server Object Explorer, under the SQL Server node, expand your connected server instance. Right-click the Databases node and select Add New Database. Rename the new database to TradeDev. Right-click the Trade database in SQL Server Object Explorer, and select Schema Compare.

What is clone database?

A database clone is a complete and separate copy of a database system that includes the business data, the DBMS software and any other application tiers that make up the environment.

Can you duplicate a database?

Expand Databases, right-click the desired database, point to Tasks, and then select Copy Database... If the Welcome to the Copy Database Wizard splash page appears, select Next. Select a Source Server page: Specify the server with the database to move or copy.


1 Answers

You must have added these objects to your model database by mistake at some point.

This gets used as the template for all new databases. Any objects created in there will be present in new databases CREATE-ed.

like image 101
Martin Smith Avatar answered Sep 22 '22 20:09

Martin Smith