📜  以编程方式创建 sql server 数据库 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:04:51.534000             🧑  作者: Mango

代码示例1
String str;
 SqlConnection myConn = new SqlConnection ("Server=localhost;Integrated security=SSPI;database=master");

str = "CREATE DATABASE MyDatabase ON PRIMARY " +
 "(NAME = MyDatabase_Data, " +
 "FILENAME = 'C:\\MyDatabaseData.mdf', " +
 "SIZE = 2MB, MAXSIZE = 10MB, FILEGROWTH = 10%)" +
 "LOG ON (NAME = MyDatabase_Log, " +
 "FILENAME = 'C:\\MyDatabaseLog.ldf', " +
 "SIZE = 1MB, " +
 "MAXSIZE = 5MB, " +
 "FILEGROWTH = 10%)";

SqlCommand myCommand = new SqlCommand(str, myConn);
try
{