DocsDataBasesMicrosoft SQL Server

Microsoft SQL Server

Blueprint setup for Microsoft SQL Server queries and image data in Unreal Engine

Before You Start

  • Install a compatible SQL Server ODBC driver on the Windows machine running the game or editor.
  • Know the server name, instance or address, database name, and login method.
  • For Windows Authentication, make sure the Windows account running the game has access to the database.
  • For username/password authentication, make sure SQL Server authentication is enabled on the server.

Blueprint Connection Steps

  1. Open the Blueprint that should own the database connection.
  2. Add the Microsoft SQL Server connection component from this product, or place the Microsoft SQL Server connection actor in the level and reference it.
  3. On your setup event, add MakeMSSQLConnectionParams.
  4. Fill Server and Database.
  5. If using SQL login, fill Username and Password.
  6. If using Windows Authentication, enable bUseWindowsAuthentication.
  7. Add ODBC settings such as encryption or certificate trust to ExtraParams when needed.
  8. Use ConnectionStringOverride only when you need to provide the full ODBC string yourself.
  9. Pass the params into CreateConnection.
  10. Bind OnConnectionStatusChanged, OnConnectionInvalid, OnQuerySelectStatusChanged, and OnQueryUpdateStatusChanged.

Run a Select Query

  1. Wait until the connection reports success.
  2. Call SelectDataFromQuery.
SELECT TOP 10 Id, DisplayName, Score
FROM dbo.Leaderboard
ORDER BY Score DESC;
  1. Use the select status event to check success or read the error message.
  2. Use the returned Blueprint rows/table to update UMG widgets or gameplay state.

Run an Insert, Update, or Delete

  1. Call UpdateDataFromQuery for statements that change data.
  2. Bind OnQueryUpdateStatusChanged to show progress and failures to the player or tool user.
UPDATE dbo.Leaderboard
SET Score = 3200
WHERE Id = 7;

Image and BLOB Workflow

This workflow is currently specific to Microsoft SQL Server. It is not enabled for PostgreSQL or MySQL in this package.

  1. Create a table column that can store binary image data, such as VARBINARY(MAX).
  2. Connect to SQL Server using the steps above.
  3. To upload an image from Blueprint, call UpdateImageData with the file path or supported image input and the SQL update statement.
  4. To load an image back into Unreal, call SelectImageDataFromQuery.
  5. Bind the image select status event and use the returned Texture2D in UMG, materials, or runtime display actors.
SELECT TOP 1 PortraitImage
FROM dbo.PlayerPortraits
WHERE PlayerId = 7;

Microsoft SQL Notes

  • The default generated connection path targets the SQL Server ODBC driver flow.
  • Use Trusted_Connection through the Windows Authentication option instead of typing a Windows password into Blueprint.
  • Use ConnectionStringOverride for named instances, DSN paths, non-default drivers, or enterprise security strings.
  • Close the connection when your owning Blueprint is finished with it.
DataBases - Microsoft SQL Server | Athian Games