Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9184973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:10:58+00:00 2026-06-17T19:10:58+00:00

I created a sql script to check if a database already exist, if it

  • 0

I created a sql script to check if a database already exist, if it already exists it deletes and re-creates.
After I would like to connect it directly after its creation for creating tables ..

Here is my code but it does not work.
He announces an error message

Msg 911, Level 16, State 1, Line 10
Database ‘Arms2’ does not exist. Make sure that the name is entered correctly.

My script

IF EXISTS (select * from sys.databases where name = 'Arms2')
BEGIN 
    DROP DATABASE Arms2
    PRINT 'DROP DATABASE Arms2'
END
    CREATE DATABASE Arms2;
    PRINT 'CREATE DATABASE Arms2'

USE Arms2

CREATE TABLE .....
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:10:59+00:00Added an answer on June 17, 2026 at 7:10 pm

    Put a GO statement after the CREATE…

    ...
    CREATE DATABASE Arms2;
    PRINT 'CREATE DATABASE Arms2'
    GO
    USE Arms2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create an SQL script that creates a database. Right now, I
I need to check if a database link already exists before I create one.
I have a script task that executes a dynamically created SQL restore statement. This
I have an SQL script which creates a scheduled event: CREATE EVENT Daily_1200PM SCHEDULE
I am creating a SQL script file in MySQL. The script simply creates a
I'm trying to write a script which lists a directory and creates an SQL
I have created a user in SQL-2008 R2 using the following script Use [CamelotShiftManagement]
import pyodbc cnxn = pyodbc.connect('DRIVER={SQL Server};' + 'SERVER=' + data.dbConnection()[0] + ';' + 'DATABASE='
I used SQL server 2008 script wizard to create a script that would recreate
I am trying to execute a sql script which creates a procedure and execute

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.