---
product: Chilkat
product_version: 11.7.0
language: sqlserver
language_label: SQL Server
class: Secrets
license: bundle
deprecated: false
reference_html: https://www.chilkatsoft.com/refdoc/sqlserver_SecretsRef.html
---
# Chilkat Secrets — SQL Server — v11.7.0

> Chilkat 11.7.0 · language=sqlserver · class=Secrets
> Other versions: replace `11.7.0` in this URL. Other languages: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/<lang>/classes/Secrets.md`.
> Language-wide rules (install, unlock, error model, strings/bytes): `https://www.chilkatsoft.com/ai-docs/v/11.7.0/sqlserver/guide.md`.

## Purpose

**Manage application secrets through one consistent API.**

`Chilkat.Secrets` provides a unified interface for storing, retrieving, listing, and deleting secrets across local, cloud-based, and in-memory secret stores. It supports string, binary, and JSON secrets, making it useful for passwords, API keys, OAuth credentials, tokens, unlock codes, certificates, and private configuration data.

**Local secure storage**

- Windows Credential Manager
- Apple Keychain

**Cloud secret managers**

- AWS Secrets Manager
- Azure Key Vault
- IBM Cloud Secrets Manager
- Oracle Cloud Secrets
- Doppler Secrets

**Temporary secrets**

Use in-memory secrets when values should exist only for the lifetime of the running process.

**Flexible content types**

Store and retrieve secrets as strings, binary data, or structured JSON.

**Note:** Cloud-based secret managers often require local bootstrap credentials. These can be stored securely in the Windows Credential Manager or Apple Keychain and then used to authenticate to the cloud secret manager.

Start with the [Conceptual Overview](https://www.chilkatsoft.com/chilkat_secrets_api.asp) and [Components of a Secret Name](https://www.chilkatsoft.com/components_of_a_secret_name.asp). For an extended overview, see the [Secrets Class Overview](https://www.chilkatsoft.com/secrets_class_overview.asp).

## Object creation, unlocking and error handling

**Object Creation**

```sql
DECLARE @hr int
DECLARE @secrets int
EXEC @hr = sp_OACreate 'Chilkat.Secrets', @secrets OUT
IF @hr <> 0
BEGIN
    PRINT 'Failed to create ActiveX component'
    RETURN
END

-- ... use @secrets ...

EXEC @hr = sp_OADestroy @secrets
```

T-SQL uses the Chilkat ActiveX through the OLE Automation stored procedures. They must be enabled once on the server (`EXEC sp_configure 'Ole Automation Procedures', 1; RECONFIGURE;`), and the Chilkat ActiveX registered must match the bitness of the SQL Server instance (64-bit for a 64-bit SQL Server). To bind to a specific major version of Chilkat, append the major version number to the ProgID, such as `sp_OACreate 'Chilkat.Secrets.11'` for Chilkat v11.\*.\*.

`sp_OACreate` returns an object token (an `int`) that is passed as the first argument of every `sp_OAMethod`, `sp_OAGetProperty` and `sp_OASetProperty` call, and released with `sp_OADestroy`. Objects returned by methods (such as an `HttpResponse` or `JsonObject`) are also tokens received through an `int` OUT parameter; they must likewise be destroyed, and the OUT parameter is `NULL` when the method fails to return an object. Objects passed as arguments are passed by their token. When an OLE Automation procedure itself fails (non-zero `@hr`), `sp_OAGetErrorInfo` describes the error.

Data types: strings are `nvarchar(4000)`; integers, booleans (1 or 0) and object tokens are `int`; dates are `datetime`. In the signatures on this page, `@success`, `@iResult`, `@sResult` and the like are the OUT variables receiving a method's return value, `@iValue` / `@sValue` receive or supply a property value, and the remaining `@` variables are the method's arguments in order.

A string returned through an OUT parameter is limited to 4000 characters. For longer values, retrieve the result as a result set into a table variable instead of an OUT parameter, for example `DECLARE @tmp TABLE (outputLine ntext)` followed by `INSERT INTO @tmp EXEC sp_OAGetProperty @secrets, 'LastErrorText'`. See [string length limitations for strings returned by sp_OAMethod calls](https://www.chilkatsoft.com/sql_server_nvarchar_max_limitation.asp).

Methods that pass or return raw byte arrays are not shown on this page, because `varbinary(max)` values cannot be exchanged through `sp_OAMethod` (see [varbinary(max) limitation](https://www.chilkatsoft.com/sql_server_varbinary_max_limitation.asp)). Use the `BinData`-based alternatives (methods ending in *Bd*) or the base64 / hex string-encoded variants instead. Binary *properties* (such as `LastBinaryResult`) can be retrieved as a result set into a table variable, as shown in their signatures. Asynchronous (*\*Async*) methods and event callbacks are not available from SQL Server.

Call `Global.UnlockBundle` once at the start of the program, before using this or any other Chilkat class. Any string unlocks a fully functional 30-day trial; a purchased unlock code is used in production. See `guide.md` for the exact code in SQL Server.

How failure is reported depends on the method's return type and is stated in the note under each method below. In every case the diagnostic text is in the `LastErrorText` property of the object whose method was called.

## Members common to every Chilkat class

Documented once per language in `common-members.md`; listed here so this page is self-contained.

| Property | Signature | Access | Meaning |
|---|---|---|---|
| `DebugLogFilePath` | `EXEC sp_OAGetProperty @secrets, 'DebugLogFilePath', @sValue OUT EXEC sp_OASetProperty @secrets, 'DebugLogFilePath', @sValue` | read/write | If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. |
| `LastBinaryResult` | `INSERT INTO @tmp EXEC sp_OAGetProperty @secrets, 'LastBinaryResult'` | read-only | This property is mainly used in SQL Server stored procedures to retrieve binary data from the last method call that returned binary data. |
| `LastErrorHtml` | `EXEC sp_OAGetProperty @secrets, 'LastErrorHtml', @sValue OUT` | read-only | Provides HTML-formatted information about the last called method or property. |
| `LastErrorText` | `EXEC sp_OAGetProperty @secrets, 'LastErrorText', @sValue OUT` | read-only | Provides plain text information about the last called method or property. |
| `LastErrorXml` | `EXEC sp_OAGetProperty @secrets, 'LastErrorXml', @sValue OUT` | read-only | Provides XML-formatted information about the last called method or property. |
| `LastMethodSuccess` | `EXEC sp_OAGetProperty @secrets, 'LastMethodSuccess', @iValue OUT EXEC sp_OASetProperty @secrets, 'LastMethodSuccess', @iValue` | read/write | Indicates the success or failure of the most recent method call: `1` means success, `0` means failure. |
| `LastStringResult` | `EXEC sp_OAGetProperty @secrets, 'LastStringResult', @sValue OUT` | read-only | In SQL Server stored procedures, this property holds the string return value of the most recent method call that returns a string. |
| `LastStringResultLen` | `EXEC sp_OAGetProperty @secrets, 'LastStringResultLen', @iValue OUT` | read-only | The length, in characters, of the string contained in the LastStringResult property. |
| `VerboseLogging` | `EXEC sp_OAGetProperty @secrets, 'VerboseLogging', @iValue OUT EXEC sp_OASetProperty @secrets, 'VerboseLogging', @iValue` | read/write | If set to `1`, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. |
| `Version` | `EXEC sp_OAGetProperty @secrets, 'Version', @sValue OUT` | read-only | Version of the component/library, such as "10.1.0" |

## Member index

| Member | Kind | Signature |
|---|---|---|
| `AutoSplit` | property, read/write | `EXEC sp_OAGetProperty @secrets, 'AutoSplit', @iValue OUT EXEC sp_OASetProperty @secrets, 'AutoSplit', @iValue` |
| `Compression` | property, read/write | `EXEC sp_OAGetProperty @secrets, 'Compression', @iValue OUT EXEC sp_OASetProperty @secrets, 'Compression', @iValue` |
| `Location` | property, read/write | `EXEC sp_OAGetProperty @secrets, 'Location', @sValue OUT EXEC sp_OASetProperty @secrets, 'Location', @sValue` |
| `UncommonOptions` | property, read/write | `EXEC sp_OAGetProperty @secrets, 'UncommonOptions', @sValue OUT EXEC sp_OASetProperty @secrets, 'UncommonOptions', @sValue` |
| `DeleteSecret` | method | `EXEC sp_OAMethod @secrets, 'DeleteSecret', @success OUT, @jsonId` |
| `GetSecretBd` | method | `EXEC sp_OAMethod @secrets, 'GetSecretBd', @success OUT, @jsonId, @bd` |
| `GetSecretJson` | method | `EXEC sp_OAMethod @secrets, 'GetSecretJson', @success OUT, @jsonId, @jsonOut` |
| `GetSecretSb` | method | `EXEC sp_OAMethod @secrets, 'GetSecretSb', @success OUT, @jsonId, @sb` |
| `GetSecretStr` | method | `EXEC sp_OAMethod @secrets, 'GetSecretStr', @sResult OUT, @jsonId` |
| `ListSecrets` | method | `EXEC sp_OAMethod @secrets, 'ListSecrets', @success OUT, @json, @jsonOut` |
| `SecretSpecToJson` | method | `EXEC sp_OAMethod @secrets, 'SecretSpecToJson', @success OUT, @secretSpec, @json` |
| `SetBootstrapSecret` | method | `EXEC sp_OAMethod @secrets, 'SetBootstrapSecret', @success OUT, @jsonId, @secretContent` |
| `UpdateSecretBd` | method | `EXEC sp_OAMethod @secrets, 'UpdateSecretBd', @success OUT, @jsonId, @secret` |
| `UpdateSecretJson` | method | `EXEC sp_OAMethod @secrets, 'UpdateSecretJson', @success OUT, @jsonId, @secret` |
| `UpdateSecretSb` | method | `EXEC sp_OAMethod @secrets, 'UpdateSecretSb', @success OUT, @jsonId, @sb` |
| `UpdateSecretStr` | method | `EXEC sp_OAMethod @secrets, 'UpdateSecretStr', @success OUT, @jsonId, @secret` |

## Properties

### Secrets.AutoSplit

`Chilkat 11.7.0 · sqlserver · Secrets · AutoSplit · property · read/write · since 10.1.0`

```sql
EXEC sp_OAGetProperty @secrets, 'AutoSplit', @iValue OUT
EXEC sp_OASetProperty @secrets, 'AutoSplit', @iValue
```

The AutoSplit property is specific to `local_manager` secrets on Windows. The Windows Credentials Manager supports a maximum of 2560 bytes per secret. If a secret exceeds this size, it will be automatically compressed and split when created or updated, and automatically recomposed when retrieved.

A secret can be split into a maximum of 10 parts.

The default value is `1`.

### Secrets.Compression

`Chilkat 11.7.0 · sqlserver · Secrets · Compression · property · read/write · since 10.1.0`

```sql
EXEC sp_OAGetProperty @secrets, 'Compression', @iValue OUT
EXEC sp_OASetProperty @secrets, 'Compression', @iValue
```

If set to `1`, then the contents of the secret will be stored compressed. The default value of this property is `0`.

### Secrets.Location

`Chilkat 11.7.0 · sqlserver · Secrets · Location · property · read/write · since 10.1.0`

```sql
EXEC sp_OAGetProperty @secrets, 'Location', @sValue OUT
EXEC sp_OASetProperty @secrets, 'Location', @sValue
```

The location of the secrets. Possible values are:

- `local_manager` - On Windows this is the Credentials Manager. On MacOS and iOS it is the Keychain. This is not yet an option on Linux or Android.
- `aws_secrets_manager` - AWS Secrets Manager
- `azure_key_vault` - Azure Key Vault
- `ibm_cloud` - IBM Cloud Secrets Manager
- `oracle_cloud` - Oracle Cloud Secrets
- `doppler` - Doppler Secrets
- `memory` - In-Memory Secrets

The default location is the `local_manager`. On Linux and Android, `local_manager` will behave the same as `memory`.

### Secrets.UncommonOptions

`Chilkat 11.7.0 · sqlserver · Secrets · UncommonOptions · property · read/write · since 10.1.0`

```sql
EXEC sp_OAGetProperty @secrets, 'UncommonOptions', @sValue OUT
EXEC sp_OASetProperty @secrets, 'UncommonOptions', @sValue
```

This is a catch-all property to be used for uncommon needs. This property defaults to the empty string and should typically remain empty.

## Methods

### Secrets.DeleteSecret

`Chilkat 11.7.0 · sqlserver · Secrets · DeleteSecret · method · since 10.1.0`

```sql
EXEC sp_OAMethod @secrets, 'DeleteSecret', @success OUT, @jsonId
```

Deletes a secret. Cloud secrets managers will typically disable the secret and schedule the secret for deletion after some number of days.

Returns 1 for success, 0 for failure.

### Secrets.GetSecretBd

`Chilkat 11.7.0 · sqlserver · Secrets · GetSecretBd · method · since 10.1.0`

```sql
EXEC sp_OAMethod @secrets, 'GetSecretBd', @success OUT, @jsonId, @bd
```

Fetches a binary secret and returns the content in `bd`.

Returns 1 for success, 0 for failure.

### Secrets.GetSecretJson

`Chilkat 11.7.0 · sqlserver · Secrets · GetSecretJson · method · since 10.1.0`

```sql
EXEC sp_OAMethod @secrets, 'GetSecretJson', @success OUT, @jsonId, @jsonOut
```

Fetches a JSON secret and returns the content in `jsonOut`.

Returns 1 for success, 0 for failure.

### Secrets.GetSecretSb

`Chilkat 11.7.0 · sqlserver · Secrets · GetSecretSb · method · since 10.1.0`

```sql
EXEC sp_OAMethod @secrets, 'GetSecretSb', @success OUT, @jsonId, @sb
```

Fetches a string secret and returns the content in `sb`.

Returns 1 for success, 0 for failure.

### Secrets.GetSecretStr

`Chilkat 11.7.0 · sqlserver · Secrets · GetSecretStr · method · since 10.1.0`

```sql
EXEC sp_OAMethod @secrets, 'GetSecretStr', @sResult OUT, @jsonId
```

Fetches a string secret and returns the content of the secret.

Returns `NULL` on failure

### Secrets.ListSecrets

`Chilkat 11.7.0 · sqlserver · Secrets · ListSecrets · method · since 10.1.0`

```sql
EXEC sp_OAMethod @secrets, 'ListSecrets', @success OUT, @json, @jsonOut
```

Lists secrets matching the wildcarded or exact values passed in `json`. The results of the query are returned in `jsonOut`.

Returns 1 for success, 0 for failure.

### Secrets.SecretSpecToJson

`Chilkat 11.7.0 · sqlserver · Secrets · SecretSpecToJson · method · since 11.5.0`

```sql
EXEC sp_OAMethod @secrets, 'SecretSpecToJson', @success OUT, @secretSpec, @json
```

Converts a secret specification string (`secretSpec`) to JSON. A secret specification string is formatted as "!!part1\|part2\|part3\|part4" where parts 3 and 4 are optional. `json` is the output argument.

Returns 1 for success, 0 for failure.

### Secrets.SetBootstrapSecret

`Chilkat 11.7.0 · sqlserver · Secrets · SetBootstrapSecret · method · since 10.1.0`

```sql
EXEC sp_OAMethod @secrets, 'SetBootstrapSecret', @success OUT, @jsonId, @secretContent
```

Accessing a cloud-based secrets manager requires authentication credentials, which cannot be stored in the manager itself. Instead, they must be securely stored locally.

One solution is to store the authentication credentials as a secret in the Windows Credentials Manager or Apple Keychain. These credentials serve as the `bootstrap secret` for authenticating with the cloud-based secrets manager.

`jsonId` contains the name of the bootstrap secret. `secretContent` contains the bootstrap's secret content.

Returns 1 for success, 0 for failure.

### Secrets.UpdateSecretBd

`Chilkat 11.7.0 · sqlserver · Secrets · UpdateSecretBd · method · since 10.1.0`

```sql
EXEC sp_OAMethod @secrets, 'UpdateSecretBd', @success OUT, @jsonId, @secret
```

Creates a binary secret if it does not yet exist, or updates an existing secret. The name of the secret is specified in `jsonId`, and the binary content of the secret in `secret`.

Returns 1 for success, 0 for failure.

### Secrets.UpdateSecretJson

`Chilkat 11.7.0 · sqlserver · Secrets · UpdateSecretJson · method · since 10.1.0`

```sql
EXEC sp_OAMethod @secrets, 'UpdateSecretJson', @success OUT, @jsonId, @secret
```

Creates a JSON secret if it does not yet exist, or updates an existing secret. The name of the secret is specified in `jsonId`, and the JSON content of the secret in `secret`.

Returns 1 for success, 0 for failure.

### Secrets.UpdateSecretSb

`Chilkat 11.7.0 · sqlserver · Secrets · UpdateSecretSb · method · since 10.1.0`

```sql
EXEC sp_OAMethod @secrets, 'UpdateSecretSb', @success OUT, @jsonId, @sb
```

Creates a string secret if it does not yet exist, or updates an existing secret. The name of the secret is specified in `jsonId`, and the string content of the secret in `sb`.

Returns 1 for success, 0 for failure.

### Secrets.UpdateSecretStr

`Chilkat 11.7.0 · sqlserver · Secrets · UpdateSecretStr · method · since 10.1.0`

```sql
EXEC sp_OAMethod @secrets, 'UpdateSecretStr', @success OUT, @jsonId, @secret
```

Creates a string secret if it does not yet exist, or updates an existing secret. The name of the secret is specified in `jsonId`, and the string content of the secret in `secret`.

Note: Starting in Chilkat **v11.3.0**, if the `service` = `"Chilkat"` and the `username` = `"unlock_code"`, then the secret (which is the Chilkat unlock code) can be stored and retrieved without Chilkat being unlocked. This allows for the Chilkat unlock code itself to be persisted to a secrets manager.

Returns 1 for success, 0 for failure.

## Events and callbacks

This binding has no event callbacks.

## Related classes

[`BinData`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/sqlserver/classes/BinData.md), [`JsonObject`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/sqlserver/classes/JsonObject.md), [`StringBuilder`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/sqlserver/classes/StringBuilder.md)

