Creating a database programmatically in SQL Server

后端 未结 6 2289
情书的邮戳
情书的邮戳 2020-11-30 09:20

How can I create a database programmatically and what is the minimum information I need to do this?

Please no \"SQL Server Management Object API \"

6条回答
  •  广开言路
    2020-11-30 09:31

    You need to open a connection to the server, i.e. you need a server and instance name.

    You also need the proper access rights to create a database, so you might need some user name and password depending on the authentication settings on the server.

    From the server name and authentication information you can construct a connection string and open a connection.

    Then you can use the CREATE DATABASE SQL command (see here on MSDN). The only needed parameter for this command is a database name.

提交回复
热议问题