How to create a new database in MS SQL Server?

390 views Asked by At

Sorry, if this has been asked previously. In services on a client, I can see that MS SQL Server has the status "started". and on this machine I don't have Microsoft SQL SERVER Management Studio.

How can I create a new database?

Thank you!

4

There are 4 answers

0
Juozas On BEST ANSWER

Please use sqlcmd utility and then create script to be executed.

To execute script: sqlcmd -i C:\create_script.sql

Db create scritp example:

CREATE DATABASE testDb
GO

More about the db create options: https://msdn.microsoft.com/en-us/library/ms176061.aspx

0
swe On

There are multiple possibilities.

You can install MSSQL-Studio on any other pc and connect to your server or you can connect via any sql-client tool and create a database per sql, see MSDN.

0
TheGameiswar On

you can use SQLCMD which comes with SQLinstallation..

create a file with create database syntax and save it as .sql file

CREATE DATABASE dbname;

Then use SQLCMD..

sqlcmd -S <ComputerName>\<InstanceName> -i <MyScript.sql> -o out.txt
0
Super Kai - Kazuya Ito On

With the MSSQL queries below, you can create a database:

CREATE DATABASE testdb
GO

Then, you can show all the existed databases:

SELECT name FROM master.sys.databases
GO

master
tempdb
model
msdb
testdb

Then, you can drop(delete) a database:

DROP DATABASE testdb
GO