20

How to create new database with SQL Server Express 2008 without using Management Studio?

Do i need to download sp1?

skaffman
  • 398,947
  • 96
  • 818
  • 769
remo
  • 201
  • 1
  • 2
  • 3

3 Answers3

37

You can use the SqlCmd utility from the command line to execute SQL.

Open a command prompt and then type SqlCmd.exe and press enter, you should then get 1) which means you are connected.

Once connected execute

1) CREATE DATABASE dbname
2) GO
Chris Diver
  • 19,362
  • 4
  • 47
  • 58
  • 1
    While opening it the screen stays for 5 seconds then something is written on it and it closes instantly. How to fix this? – Aman Chhabra Feb 14 '14 at 08:03
  • 9
    You can do it in a single line: `sqlcmd -U sa -P Passw0rd -S .\SQLEXPRESS -Q "CREATE DATABASE FOO"` – Chris S Jun 09 '14 at 12:13
  • 1
    I will just add, that you don't need username and password, if our ODBC is setup to use windows authentication. E.g. when installed with Veeam. – Jesper Grann Laursen Mar 30 '15 at 12:12
  • @ChrisS i am getting an error while executing this command. On server there is no SQL Server Management Studio installed. – iamraviraj Feb 11 '16 at 13:41
2

Use CREATE DATABASE via sqlcmd or another other database connection (even VBA from Excel...)

gbn
  • 422,506
  • 82
  • 585
  • 676
0

You could connect to it in code (.net express or something) with a connectionstring, then run an sql script to create a db (see http://msdn.microsoft.com/en-us/library/ms176061.aspx).

But why can't you use the management studio?

SteveCav
  • 6,649
  • 1
  • 50
  • 52
  • on executing managemnt studio i m getting message tht i need to download sp1..can i do without using management studio. – remo Jul 09 '10 at 05:57