Share via


LocalDBCreateInstance Function

Creates a new SQL Server Express LocalDB instance.

Header file: sqlncli.h

Syntax

HRESULT LocalDBCreateInstance(
           PCWSTR wszVersion,
           PCWSTR pInstanceName, 
           DWORD dwFlags 
);

Parameters

  • wszVersion
    [Input] The LocalDB version, for example 11.0 or 11.0.1094.2.

  • pInstanceName
    [Input] The name for the LocalDB instance to create.

  • dwFlags
    [Input] Reserved for future use. Currently should be set to 0.

Returns

Remarks

If a fully functional LocalDB instance with the specified name already exists and its version is equal to or higher than requested, the result is S_OK.

In cases when an existing instance becomes corrupted, subsequent calls to the LocalDBCreateInstance API method will fail. Corrupted instances must be fixed manually or explicitly deleted before they can be used again.

For a code sample that uses LocalDB API, see SQL Server Express LocalDB Reference.

See Also

Concepts

SQL Server Express LocalDB Header and Version Information