문제

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?

도움이 되었습니까?

해결책

Yes, insert the GO command in between your scripts.

CREATE DATABASE MyDatabase
GO
USE [MyDatabase]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top