Creating an empty SQL database.
-
-
Assuming you are connected to the server as a user that has the rights to create a database (and next some tables)
CREATE DATABASE <database name>;
look up in Books Online the syntax forCREATE DATABASE
to see all the different settings you can specify. While you're looking that up, look upCREATE TABLE
too, because you'll need some tables added in order to do much with that database :)James Sig code stolen from David Wulff
-
Assuming you are connected to the server as a user that has the rights to create a database (and next some tables)
CREATE DATABASE <database name>;
look up in Books Online the syntax forCREATE DATABASE
to see all the different settings you can specify. While you're looking that up, look upCREATE TABLE
too, because you'll need some tables added in order to do much with that database :)James Sig code stolen from David Wulff
This is a sql command, and I normally use ADO's object SQLcommand and its method "command.ExecuteNonQuery()" to execute the required sql command in my C# program or ASP.NET c# server code. However, that SQLcommand object requires connection first, which needs to have a existed DB available. So in this case, sqlcommand may not be a good choice to run that creation command. Any ideas any other object I can use in my C# program? Thanks a lot!
-
This is a sql command, and I normally use ADO's object SQLcommand and its method "command.ExecuteNonQuery()" to execute the required sql command in my C# program or ASP.NET c# server code. However, that SQLcommand object requires connection first, which needs to have a existed DB available. So in this case, sqlcommand may not be a good choice to run that creation command. Any ideas any other object I can use in my C# program? Thanks a lot!
You can connect to SQL server without using a specific database. If you specify CATALOG in your connection string, remove it; and you should be ok. The account you use to connect to SQL Server (either Windows authentication or username/password authentication) needs to have permissions to create databases.
James Sig code stolen from David Wulff