Create new database sql server
Here are the steps to create a new database in SQL Server:
Step 1: Open SQL Server Management Studio
- Launch SQL Server Management Studio (SSMS) on your computer.
- If you don't have SSMS installed, you can download it from the Microsoft website.
Step 2: Connect to the Server
- In the Object Explorer, right-click on "SQL Server" and select "Connect".
- Enter the server name, authentication details (e.g., username and password), and click "Connect".
Step 3: Create a New Database
- In the Object Explorer, right-click on "Databases" and select "New Database".
- In the "New Database" dialog box, enter the following information:
- Database name: Enter a name for your new database (e.g., "MyNewDatabase").
- Owner: Select the owner of the database (e.g., "sa" or a specific user).
- Location: Select the location where the database files will be stored (e.g., "C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\DATA").
- File growth: Set the file growth options (e.g., "Auto-grow" and "File growth percentage").
- Collation: Select the collation for the database (e.g., "SQL_Latin1_General_CP1_CI_AS").
- Click "OK" to create the new database.
SQL Script
If you prefer to create a database using a SQL script, you can use the following script:
CREATE DATABASE MyNewDatabase
ON (NAME = 'MyNewDatabase', FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\DATA\MyNewDatabase.mdf', SIZE = 1024MB, MAXSIZE = 2048MB, FILEGROWTH = 10%)
LOG ON (NAME = 'MyNewDatabase_log', FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\DATA\MyNewDatabase_log.ldf', SIZE = 256MB, MAXSIZE = 512MB, FILEGROWTH = 10%)
Replace the file paths and sizes with your own values.
Verify the Database
Once the database is created, you can verify it by expanding the "Databases" folder in the Object Explorer and checking that your new database is listed.
That's it! You have now created a new database in SQL Server.