# Koppelung der SQL Express Datenbank in MDT

Die Verbindung zwischen MDT und der SQL-Express-Datenbank wird nun konfiguriert. Durch die Datenbank wird die Erfassung unterschiedlicher Bereitstellungs-Optionen erheblich vereinfacht.&#x20;

Die Konfiguration der Verknüpfung zwischen SQL-Datenbank und MDT ist komplex. Empfohlen wird daher diese Konfiguration mit Hilfe des Videos durchzuführen:

{% embed url="<https://youtu.be/uGvkvUBWI5A>" %}
Koppelung der SQL-Express-Datenbank in MDT
{% endembed %}

{% hint style="danger" %}
**Achtung!** Der Name der Datenbank muss übereinstimmen mit dem im SQL Server Configuration Manager. Der Standardname ist `SQLEXPRESS`, im Video ist er `ADK`.

Du hast dir diesen Namen bei der Installation von SSMS notiert (siehe [Installation des SQL Server Express](/server-virtualization/ch10-deployment-mit-mdt-und-adk/mdt-dienste-installieren.md#installation-des-sql-server-express-frueher-in-adk-integriert)).
{% endhint %}

Optional wird hier über die Ausführung des Skripts `SetSQLServicesMDT.ps1` die Einrichtung vereinfacht:

{% code title="ConfigSQLExpressMDT.ps1" %}

```powershell
Add-PSSnapIn Microsoft.BDD.PSSnapIn -ErrorAction SilentlyContinue 
Get-PSDrive -PSProvider Microsoft.BDD.PSSnapIn\MDTProvider  | Remove-PSDrive | Remove-MDTPersistentDrive
New-PSDrive -Name "DS001" -PSProvider MDTProvider `
  -Root "$InstallDrive\MDTProdLab" `
  -Description "MDT ProdLab" `
  -NetworkPath "\\$MDT01\MDTProdLab$"

# How to: Enable or Disable a Server Network Protocol (SQL Server PowerShell)
# https://technet.microsoft.com/en-us/library/dd206997(v=sql.105).aspx
[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo")
[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.SqlWmiManagement")
$smo = 'Microsoft.SqlServer.Management.Smo.'
$wmi = new-object ($smo + 'Wmi.ManagedComputer').
# List the object properties, including the instance names.
$Wmi
# Disable the TCP protocol on the default instance.
# $uri = "ManagedComputer[@Name='$MDTServer']/ ServerInstance[@Name='ADK']/ServerProtocol[@Name='Tcp']"
$uri = "ManagedComputer[@Name='" + (get-item env:\computername).Value + "']/ServerInstance[@Name='ADK']/ServerProtocol[@Name='Tcp']"
$Tcp = $wmi.GetSmoObject($uri)
$Tcp.IsEnabled = $false
$Tcp.Alter()
$Tcp
# Enable the named pipes protocol for the default instance.
$uri = "ManagedComputer[@Name='" + (get-item env:\computername).Value + "']/ServerInstance[@Name='ADK']/ServerProtocol[@Name='Np']"
# $uri = "ManagedComputer[@Name='$MDTServer']/ ServerInstance[@Name='ADK']/ServerProtocol[@Name='Np']"
$Np = $wmi.GetSmoObject($uri)
$Np.IsEnabled = $true
$Np.Alter()
$Np

Start-Sleep -Milliseconds 1000

Start-Process sc -ArgumentList {config sqlbrowser start= auto} -ErrorAction SilentlyContinue
Start-Service "SQL Server Browser" -ErrorAction SilentlyContinue
Stop-Service "SQL Server (ADK)"  -ErrorAction SilentlyContinue
Start-Service "SQL Server (ADK)" -ErrorAction SilentlyContinue

Start-Sleep -Milliseconds 1000

# Add a new Database
$MDTServer = (get-wmiobject win32_computersystem).Name
New-MDTDatabase -SQLServer $MDTServer -Database "DB-Prod-Lab" -Instance "ADK" -SQLShare "MDTProdLab$" -Path DS001: -Force 
```

{% endcode %}


---

# Agent Instructions: 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:

```
GET https://do-moser.gitbook.io/server-virtualization/ch10-deployment-mit-mdt-und-adk/mdt-dienste-konfigurieren/koppelung-der-sql-express-datenbank-in-mdt.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
