0

I have a script which uses an existing database to create tables and enter values. Now I wish to create the database through this same script and then create the tables and values which are just a copy of another database.

I have:

CREATE DATABASE MyDatabase

USE [MyDatabase]
....Code that creates the tables and values from another database.

The USE [MyDatabase] command is not recognized since MyDatabase does not exist anywhere yet. Is there a way around this?

zms6445
  • 317
  • 6
  • 22

1 Answers1

2

Yes, insert the GO command in between your scripts.

CREATE DATABASE MyDatabase
GO
USE [MyDatabase]
Kyle Hale
  • 7,912
  • 1
  • 37
  • 58