> For the complete documentation index, see [llms.txt](https://enterprise-ua.hideez.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://enterprise-ua.hideez.com/korporativnii-server-hideez/rozgortannya/vstanovlennya-bazi-danikh/microsoft-sql-server-na-windows.md).

# Microsoft SQL Server на Windows

#### 1. Завантаження Microsoft [SQL Server 2019 Express](https://go.microsoft.com/fwlink/?linkid=866658)

#### 2. Встановлення Microsoft SQL Server 2019 Express

* Ви можете обрати тип `Basic installation` під час установки.
* Також для керування базами даних нам потрібна SQL Server Management Studio (SSMS). Ви можете завантажити його [тут](https://aka.ms/ssmsfullsetup).
* Також, як альтернативу Server Management Studio, Ви можете використовувати `sqlcmd`. Утиліта `sqlcmd` дозволяє вводити оператори Transact-SQL, системні процедури та файли сценаріїв у командному рядку.

#### 3. Дозвіл TCP/IP підключень

HES використовує TCP/IP для підключення до бази даних SQL Server, але SQL Server Express не вмикає підтримку TCP за замовчуванням. Щоб увімкнути TCP/IP:

3.1. У диспетчері конфігурації SQL Server розгорніть елемент `SQL Server Network Configuration` -> `Protocols for SQLEXPRESS`.

3.2. Клацніть правою кнопкою миші `TCP/IP` справа, а потім виберіть `Properties`.

3.3. На вкладці `General`, змініть `Enabled` на **Yes**.

3.4. На вкладці `IP Addresses`, в елементі `IPAll`, очистіть `TCP Dynamic Ports`.

3.5. У `TCP Port`, введіть прослуховування порта **1433**. Цей порт має використовуватися в рядку підключення HES.

3.6. Натисніть OK.

3.7. Перезапустіть службу Microsoft SQL Server Express за допомогою стандартної панелі керування службою або інструментів SQL Express.

#### 4. Змініть режим автентифікації

4.1. Запустіть SQL Server Management Studio та підключіться до сервера.

4.2. У `Object Explorer`, клацніть правою кнопкою миші екземпляр SQL Express і виберіть `Properties`.

4.3. Оберіть зліва розділ `Security`.

4.5. Змініть `Server Authentication` на **SQL Server and Windows Authentication mode**.

4.6. Перезапустіть сервіс Microsoft SQL Server Express використовуючи стандартну контрольну панель або інструменти SQL Express.

#### 5. Створення користувача та бази даних SQL Server

**Створіть користувача в Server Management Studio:**

5.1. Запустіть SQL Server Management Studio та підключіться до сервера.

5.2. У `Object Explorer` перейдіть до `Security` -> `Logins`, натисніть правою кнопкою миші елемент `Logins` та оберіть `New Login`.

5.3. У вікні "login new":

* Введіть ім'я користувача: `hesuser`.
* Змініть `Windows authentication` на `SQL Server аuthentication`.
* Введіть пароль користувача.
* Відключіть `Enforce password expiration`.
* Натисніть OK.

**Створіть базу даних у Server Management Studio:**

5.4. У `Object Explorer` перейдіть до `Databases`, натисніть правою кнопкою миші `Databases`, далі оберіть `New Database`.

* Введіть ім'я бази даних: `hesdb`
* оберіть власника (користувач з попереднього кроку).
* Натисніть OK.

**Альтернативним способом створення бази даних і користувача є використання утиліти sqlcmd.**

5.1. Запустіть SQLCMD, введіть "sqlcmd" у пошуку Windows.

Наступні рядки створюють базу даних `hesdb`, користувача `hesuser` з паролем `<user_password>`. Змініть `<user_password>` на ваш справжній пароль:

```
> CREATE LOGIN [hesuser]  WITH PASSWORD = 'user_password';
> GO
> CREATE DATABASE hesdb;
> GO
> USE hesdb; 
> GO
> CREATE USER [hesuser] from login [hesuser];
> GO
> GRANT CONTROL ON DATABASE::hesdb  TO [hesuser];
> GO
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://enterprise-ua.hideez.com/korporativnii-server-hideez/rozgortannya/vstanovlennya-bazi-danikh/microsoft-sql-server-na-windows.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
