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

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

## Purpose

**Load, inspect, build, edit, and encode ASN.1 structures in DER or XML form.**

`Chilkat.Asn` represents an ASN.1 item and its optional child items. It can load ASN.1 from binary DER, encoded DER strings, files, or `BinData`; expose tags, tag values, primitive content, boolean and integer values, and child counts; build constructed structures such as `SEQUENCE` and `SET`; append common primitive types such as booleans, integers, big integers, bit strings, octets, OIDs, strings, times, null values, and context-specific items; convert ASN.1 to XML; reload from that XML form; and write the final structure back to DER.

**Load DER data**

Load ASN.1 from binary DER bytes, encoded text such as Base64 or hex, files, or existing `BinData` objects.

**Inspect ASN.1 items**

Read the item tag, tag value, constructed/primitive state, sub-item count, string content, boolean value, or integer value.

**Build sequences and sets**

Append constructed `SEQUENCE` and `SET` items, then add child ASN.1 values beneath them.

**Append primitive values**

Add booleans, integers, big integers, bit strings, octet strings, OIDs, strings, times, null values, and encoded byte content.

**Context-specific tags**

Add context-specific primitive or constructed items when working with ASN.1 formats that use tagged application-specific structures.

**DER and XML conversion**

Convert ASN.1 to XML for inspection or editing, load ASN.1 back from XML, and output the result as binary or encoded DER.

**Common pattern:** Load existing DER with `LoadBinary`, `LoadEncoded`, `LoadBd`, or `LoadBinaryFile`, inspect the tree with `Tag`, `Constructed`, `NumSubItems`, and `GetSubItem`, then extract primitive content or convert to XML with `AsnToXml`. To create ASN.1, start with a constructed item, append child values, and write the final DER with `GetBinaryDer`, `GetEncodedDer`, `WriteBd`, or `WriteBinaryDer`.

## Object creation, unlocking and error handling

**Object Creation**

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

-- ... use @asn ...

EXEC @hr = sp_OADestroy @asn
```

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.Asn.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 @asn, '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 @asn, 'DebugLogFilePath', @sValue OUT EXEC sp_OASetProperty @asn, '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 @asn, '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 @asn, 'LastErrorHtml', @sValue OUT` | read-only | Provides HTML-formatted information about the last called method or property. |
| `LastErrorText` | `EXEC sp_OAGetProperty @asn, 'LastErrorText', @sValue OUT` | read-only | Provides plain text information about the last called method or property. |
| `LastErrorXml` | `EXEC sp_OAGetProperty @asn, 'LastErrorXml', @sValue OUT` | read-only | Provides XML-formatted information about the last called method or property. |
| `LastMethodSuccess` | `EXEC sp_OAGetProperty @asn, 'LastMethodSuccess', @iValue OUT EXEC sp_OASetProperty @asn, '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 @asn, '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 @asn, 'LastStringResultLen', @iValue OUT` | read-only | The length, in characters, of the string contained in the LastStringResult property. |
| `VerboseLogging` | `EXEC sp_OAGetProperty @asn, 'VerboseLogging', @iValue OUT EXEC sp_OASetProperty @asn, '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 @asn, 'Version', @sValue OUT` | read-only | Version of the component/library, such as "10.1.0" |

## Member index

| Member | Kind | Signature |
|---|---|---|
| `BoolValue` | property, read/write | `EXEC sp_OAGetProperty @asn, 'BoolValue', @iValue OUT EXEC sp_OASetProperty @asn, 'BoolValue', @iValue` |
| `Constructed` | property, read-only | `EXEC sp_OAGetProperty @asn, 'Constructed', @iValue OUT` |
| `ContentStr` | property, read/write | `EXEC sp_OAGetProperty @asn, 'ContentStr', @sValue OUT EXEC sp_OASetProperty @asn, 'ContentStr', @sValue` |
| `IntValue` | property, read/write | `EXEC sp_OAGetProperty @asn, 'IntValue', @iValue OUT EXEC sp_OASetProperty @asn, 'IntValue', @iValue` |
| `NumSubItems` | property, read-only | `EXEC sp_OAGetProperty @asn, 'NumSubItems', @iValue OUT` |
| `Tag` | property, read-only | `EXEC sp_OAGetProperty @asn, 'Tag', @sValue OUT` |
| `TagValue` | property, read-only | `EXEC sp_OAGetProperty @asn, 'TagValue', @iValue OUT` |
| `AppendBigInt` | method | `EXEC sp_OAMethod @asn, 'AppendBigInt', @success OUT, @encodedBytes, @encoding` |
| `AppendBits` | method | `EXEC sp_OAMethod @asn, 'AppendBits', @success OUT, @encodedBytes, @encoding` |
| `AppendBool` | method | `EXEC sp_OAMethod @asn, 'AppendBool', @success OUT, @value` |
| `AppendContextConstructed` | method | `EXEC sp_OAMethod @asn, 'AppendContextConstructed', @success OUT, @tag` |
| `AppendContextPrimitive` | method | `EXEC sp_OAMethod @asn, 'AppendContextPrimitive', @success OUT, @tag, @encodedBytes, @encoding` |
| `AppendInt` | method | `EXEC sp_OAMethod @asn, 'AppendInt', @success OUT, @value` |
| `AppendNull` | method | `EXEC sp_OAMethod @asn, 'AppendNull', @success OUT` |
| `AppendOctets` | method | `EXEC sp_OAMethod @asn, 'AppendOctets', @success OUT, @encodedBytes, @encoding` |
| `AppendOid` | method | `EXEC sp_OAMethod @asn, 'AppendOid', @success OUT, @oid` |
| `AppendSequence` | method | `EXEC sp_OAMethod @asn, 'AppendSequence', @success OUT` |
| `AppendSequence2` | method | `EXEC sp_OAMethod @asn, 'AppendSequence2', @success OUT` |
| `AppendSequenceR` | method | `EXEC sp_OAMethod @asn, 'AppendSequenceR', @asn OUT -- returns a ChilkatAsn object token` |
| `AppendSet` | method | `EXEC sp_OAMethod @asn, 'AppendSet', @success OUT` |
| `AppendSet2` | method | `EXEC sp_OAMethod @asn, 'AppendSet2', @success OUT` |
| `AppendSetR` | method | `EXEC sp_OAMethod @asn, 'AppendSetR', @asn OUT -- returns a ChilkatAsn object token` |
| `AppendString` | method | `EXEC sp_OAMethod @asn, 'AppendString', @success OUT, @strType, @value` |
| `AppendTime` | method | `EXEC sp_OAMethod @asn, 'AppendTime', @success OUT, @timeFormat, @dateTimeStr` |
| `AsnToXml` | method | `EXEC sp_OAMethod @asn, 'AsnToXml', @sResult OUT` |
| `DeleteSubItem` | method | `EXEC sp_OAMethod @asn, 'DeleteSubItem', @success OUT, @index` |
| `GetEncodedContent` | method | `EXEC sp_OAMethod @asn, 'GetEncodedContent', @sResult OUT, @encoding` |
| `GetEncodedDer` | method | `EXEC sp_OAMethod @asn, 'GetEncodedDer', @sResult OUT, @encoding` |
| `GetLastSubItem` | method | `EXEC sp_OAMethod @asn, 'GetLastSubItem', @asn OUT -- returns a ChilkatAsn object token` |
| `GetSubItem` | method | `EXEC sp_OAMethod @asn, 'GetSubItem', @asn OUT, @index -- returns a ChilkatAsn object token` |
| `LoadAsnXml` | method | `EXEC sp_OAMethod @asn, 'LoadAsnXml', @success OUT, @xmlStr` |
| `LoadBd` | method | `EXEC sp_OAMethod @asn, 'LoadBd', @success OUT, @bd` |
| `LoadBinaryFile` | method | `EXEC sp_OAMethod @asn, 'LoadBinaryFile', @success OUT, @path` |
| `LoadEncoded` | method | `EXEC sp_OAMethod @asn, 'LoadEncoded', @success OUT, @asnContent, @encoding` |
| `SetEncodedContent` | method | `EXEC sp_OAMethod @asn, 'SetEncodedContent', @success OUT, @encodedBytes, @encoding` |
| `WriteBd` | method | `EXEC sp_OAMethod @asn, 'WriteBd', @success OUT, @bd` |
| `WriteBinaryDer` | method | `EXEC sp_OAMethod @asn, 'WriteBinaryDer', @success OUT, @path` |

## Properties

### Asn.BoolValue

`Chilkat 11.7.0 · sqlserver · Asn · BoolValue · property · read/write · since 9.5.0.49`

```sql
EXEC sp_OAGetProperty @asn, 'BoolValue', @iValue OUT
EXEC sp_OASetProperty @asn, 'BoolValue', @iValue
```

The ASN.1 item's boolean value if it is a boolean item.

### Asn.Constructed

`Chilkat 11.7.0 · sqlserver · Asn · Constructed · property · read-only · since 9.5.0.49`

```sql
EXEC sp_OAGetProperty @asn, 'Constructed', @iValue OUT
```

`1` if this ASN.1 item is a constructed item. Sequence and Set items are constructed and can contain sub-items. All other tags (boolean, integer, octets, utf8String, etc.) are primitive (non-constructed).

### Asn.ContentStr

`Chilkat 11.7.0 · sqlserver · Asn · ContentStr · property · read/write · since 9.5.0.49`

```sql
EXEC sp_OAGetProperty @asn, 'ContentStr', @sValue OUT
EXEC sp_OASetProperty @asn, 'ContentStr', @sValue
```

The ASN.1 item's content if it is an ASN.1 string type (such as Utf8String, BmpString, PrintableString, VisibleString, T61String, IA5String, NumericString, or UniversalString).

### Asn.IntValue

`Chilkat 11.7.0 · sqlserver · Asn · IntValue · property · read/write · since 9.5.0.49`

```sql
EXEC sp_OAGetProperty @asn, 'IntValue', @iValue OUT
EXEC sp_OASetProperty @asn, 'IntValue', @iValue
```

The ASN.1 item's integer value if it is a small integer item.

### Asn.NumSubItems

`Chilkat 11.7.0 · sqlserver · Asn · NumSubItems · property · read-only · since 9.5.0.49`

```sql
EXEC sp_OAGetProperty @asn, 'NumSubItems', @iValue OUT
```

The number of sub-items contained within this ASN.1 item. Only constructed items, such as Sequence and Set will contain sub-iitems. Primitive items such as OIDs, octet strings, integers, etc. will never contain sub-items.

### Asn.Tag

`Chilkat 11.7.0 · sqlserver · Asn · Tag · property · read-only · since 9.5.0.49`

```sql
EXEC sp_OAGetProperty @asn, 'Tag', @sValue OUT
```

The ASN.1 item's tag as a descriptive string. Possible values are:

```
boolean
integer
bitString
octets
null
oid
utf8String
relativeOid
sequence
set
numericString
printableString
t61String
ia5String
utcTime
bmpString
```

### Asn.TagValue

`Chilkat 11.7.0 · sqlserver · Asn · TagValue · property · read-only · since 9.5.0.49`

```sql
EXEC sp_OAGetProperty @asn, 'TagValue', @iValue OUT
```

The ASN.1 item's tag as a integer value. The integer values for possible tags are as follows:

```
boolean (1)
integer (2)
bitString (3)
octets (4)
null (5)
oid (6)
utf8String (12)
relativeOid (13)
sequence (16)
set (17)
numericString (18)
printableString (19)
t61String (20)
ia5String (22)
utcTime (23)
bmpString (30)
```

## Methods

### Asn.AppendBigInt

`Chilkat 11.7.0 · sqlserver · Asn · AppendBigInt · method · since 9.5.0.49`

```sql
EXEC sp_OAMethod @asn, 'AppendBigInt', @success OUT, @encodedBytes, @encoding
```

Appends an ASN.1 integer, but one that is a big (huge) integer that is too large to be represented by an integer variable. The bytes composing the integer are passed in encoded string format (such as base64, hex, etc.). The byte order must be big-endian. The `encoding` may be any of the following encodings: `Base64`, `Hex`, `Base58`, `modBase64`, `Base32`, `UU`, `QP` (for quoted-printable), `URL` (for url-encoding), `Q`, `B`, `url_oath`, `url_rfc1738`, `url_rfc2396`, and `url_rfc3986`. The `encoding` name is case insensitive (for example, both `Base64` and `base64` are treated the same).

Returns 1 for success, 0 for failure.

### Asn.AppendBits

`Chilkat 11.7.0 · sqlserver · Asn · AppendBits · method · since 9.5.0.49`

```sql
EXEC sp_OAMethod @asn, 'AppendBits', @success OUT, @encodedBytes, @encoding
```

Appends an ASN.1 bit string to the caller's sub-items. The bytes containing the bits are passed in encoded string format (such as base64, hex, etc.). The byte order must be big-endian (MSB first). The `encoding` may be any of the following encodings: `Base64`, `Hex`, `Base58`, `modBase64`, `Base32`, `UU`, `QP` (for quoted-printable), `URL` (for url-encoding), `Q`, `B`, `url_oath`, `url_rfc1738`, `url_rfc2396`, and `url_rfc3986`. The `encoding` name is case insensitive (for example, both `Base64` and `base64` are treated the same).

Returns 1 for success, 0 for failure.

### Asn.AppendBool

`Chilkat 11.7.0 · sqlserver · Asn · AppendBool · method · since 9.5.0.49`

```sql
EXEC sp_OAMethod @asn, 'AppendBool', @success OUT, @value
```

Appends an ASN.1 boolean item to the caller's sub-items. Items may only be appended to constructed data types such as Sequence and Set.

Returns 1 for success, 0 for failure.

### Asn.AppendContextConstructed

`Chilkat 11.7.0 · sqlserver · Asn · AppendContextConstructed · method · since 9.5.0.50`

```sql
EXEC sp_OAMethod @asn, 'AppendContextConstructed', @success OUT, @tag
```

Appends an ASN.1 context-specific constructed item to the caller's sub-items.

Returns 1 for success, 0 for failure.

### Asn.AppendContextPrimitive

`Chilkat 11.7.0 · sqlserver · Asn · AppendContextPrimitive · method · since 9.5.0.50`

```sql
EXEC sp_OAMethod @asn, 'AppendContextPrimitive', @success OUT, @tag, @encodedBytes, @encoding
```

Appends an ASN.1 context-specific primitive item to the caller's sub-items. The bytes are passed in encoded string format (such as base64, hex, etc.). The `encoding` may be any of the following encodings: `Base64`, `Hex`, `Base58`, `modBase64`, `Base32`, `UU`, `QP` (for quoted-printable), `URL` (for url-encoding), `Q`, `B`, `url_oath`, `url_rfc1738`, `url_rfc2396`, and `url_rfc3986`. The `encoding` name is case insensitive (for example, both `Base64` and `base64` are treated the same).

Returns 1 for success, 0 for failure.

### Asn.AppendInt

`Chilkat 11.7.0 · sqlserver · Asn · AppendInt · method · since 9.5.0.49`

```sql
EXEC sp_OAMethod @asn, 'AppendInt', @success OUT, @value
```

Appends an ASN.1 integer item to the caller's sub-items. Items may only be appended to constructed data types such as Sequence and Set.

Returns 1 for success, 0 for failure.

### Asn.AppendNull

`Chilkat 11.7.0 · sqlserver · Asn · AppendNull · method · since 9.5.0.49`

```sql
EXEC sp_OAMethod @asn, 'AppendNull', @success OUT
```

Appends an ASN.1 null item to the caller's sub-items. Items may only be appended to constructed data types such as Sequence and Set.

Returns 1 for success, 0 for failure.

### Asn.AppendOctets

`Chilkat 11.7.0 · sqlserver · Asn · AppendOctets · method · since 9.5.0.49`

```sql
EXEC sp_OAMethod @asn, 'AppendOctets', @success OUT, @encodedBytes, @encoding
```

Appends an ASN.1 octet string to the caller's sub-items. The bytes are passed in encoded string format (such as base64, hex, etc.). The `encoding` may be any of the following encodings: `Base64`, `Hex`, `Base58`, `modBase64`, `Base32`, `UU`, `QP` (for quoted-printable), `URL` (for url-encoding), `Q`, `B`, `url_oath`, `url_rfc1738`, `url_rfc2396`, and `url_rfc3986`. The `encoding` name is case insensitive (for example, both `Base64` and `base64` are treated the same).

Returns 1 for success, 0 for failure.

### Asn.AppendOid

`Chilkat 11.7.0 · sqlserver · Asn · AppendOid · method · since 9.5.0.49`

```sql
EXEC sp_OAMethod @asn, 'AppendOid', @success OUT, @oid
```

Appends an ASN.1 OID (object identifier) to the caller's sub-items. The OID is passed in string form, such as `1.2.840.113549.1.9.1`.

Returns 1 for success, 0 for failure.

### Asn.AppendSequence

`Chilkat 11.7.0 · sqlserver · Asn · AppendSequence · method · since 9.5.0.49`

```sql
EXEC sp_OAMethod @asn, 'AppendSequence', @success OUT
```

Appends an ASN.1 sequence item to the caller's sub-items.

Returns 1 for success, 0 for failure.

### Asn.AppendSequence2

`Chilkat 11.7.0 · sqlserver · Asn · AppendSequence2 · method · since 9.5.0.50`

```sql
EXEC sp_OAMethod @asn, 'AppendSequence2', @success OUT
```

Appends an ASN.1 sequence item to the caller's sub-items, and updates the internal reference to point to the newly appended sequence item.

Returns 1 for success, 0 for failure.

### Asn.AppendSequenceR

`Chilkat 11.7.0 · sqlserver · Asn · AppendSequenceR · method · since 9.5.0.50`

```sql
EXEC sp_OAMethod @asn, 'AppendSequenceR', @asn OUT  -- returns a ChilkatAsn object token
```

Appends an ASN.1 sequence item to the caller's sub-items, and returns the newly appended sequence item.

Returns `NULL` on failure

### Asn.AppendSet

`Chilkat 11.7.0 · sqlserver · Asn · AppendSet · method · since 9.5.0.49`

```sql
EXEC sp_OAMethod @asn, 'AppendSet', @success OUT
```

Appends an ASN.1 set item to the caller's sub-items.

Returns 1 for success, 0 for failure.

### Asn.AppendSet2

`Chilkat 11.7.0 · sqlserver · Asn · AppendSet2 · method · since 9.5.0.50`

```sql
EXEC sp_OAMethod @asn, 'AppendSet2', @success OUT
```

Appends an ASN.1 set item to the caller's sub-items, and updates the internal reference to point to the newly appended set item.

Returns 1 for success, 0 for failure.

### Asn.AppendSetR

`Chilkat 11.7.0 · sqlserver · Asn · AppendSetR · method · since 9.5.0.50`

```sql
EXEC sp_OAMethod @asn, 'AppendSetR', @asn OUT  -- returns a ChilkatAsn object token
```

Appends an ASN.1 set item to the caller's sub-items, and returns the newly appended set item.

Returns `NULL` on failure

### Asn.AppendString

`Chilkat 11.7.0 · sqlserver · Asn · AppendString · method · since 9.5.0.49`

```sql
EXEC sp_OAMethod @asn, 'AppendString', @success OUT, @strType, @value
```

Appends a string item to the caller's sub-items. The `strType` specifies the type of string to be added. It may be `utf8`, `ia5`, `t61`, `printable`, `visible`, `numeric`, `universal`, or `bmp`. The `value` must conform to the ASN.1 restrictions imposed for a given string type. The `utf8`, `bmp`, and `universal` types have no restrictions on what characters are allowed. In general, unless a specific type of string is required, choose the `utf8` type.

Returns 1 for success, 0 for failure.

### Asn.AppendTime

`Chilkat 11.7.0 · sqlserver · Asn · AppendTime · method · since 9.5.0.49`

```sql
EXEC sp_OAMethod @asn, 'AppendTime', @success OUT, @timeFormat, @dateTimeStr
```

Appends a UTCTime item to the caller's sub-items. The `timeFormat` specifies the format of the `dateTimeStr`. It should be set to `utc`. (In the future, this method will be expanded to append GeneralizedTime items by using `generalized` for `timeFormat`.) To append the current date/time, set `dateTimeStr` equal to the empty string or the keyword `now`. Otherwise, the `dateTimeStr` should be in the UTC time format `YYMMDDhhmm[ss]Z` or `YYMMDDhhmm[ss](+|-)hhmm`.

Returns 1 for success, 0 for failure.

### Asn.AsnToXml

`Chilkat 11.7.0 · sqlserver · Asn · AsnToXml · method · since 9.5.0.49`

```sql
EXEC sp_OAMethod @asn, 'AsnToXml', @sResult OUT
```

Converts ASN.1 to XML and returns the XML string.

Returns `NULL` on failure

### Asn.DeleteSubItem

`Chilkat 11.7.0 · sqlserver · Asn · DeleteSubItem · method · since 9.5.0.49`

```sql
EXEC sp_OAMethod @asn, 'DeleteSubItem', @success OUT, @index
```

Discards the Nth sub-item. (The 1st sub-item is at index 0.)

Returns 1 for success, 0 for failure.

### Asn.GetEncodedContent

`Chilkat 11.7.0 · sqlserver · Asn · GetEncodedContent · method · since 9.5.0.49`

```sql
EXEC sp_OAMethod @asn, 'GetEncodedContent', @sResult OUT, @encoding
```

Returns the content of the ASN.1 item in encoded string form. The `encoding` may be any of the following encodings: `Base64`, `Hex`, `Base58`, `modBase64`, `Base32`, `UU`, `QP` (for quoted-printable), `URL` (for url-encoding), `Q`, `B`, `url_oath`, `url_rfc1738`, `url_rfc2396`, and `url_rfc3986`. The `encoding` name is case insensitive (for example, both `Base64` and `base64` are treated the same).

Returns `NULL` on failure

### Asn.GetEncodedDer

`Chilkat 11.7.0 · sqlserver · Asn · GetEncodedDer · method · since 9.5.0.49`

```sql
EXEC sp_OAMethod @asn, 'GetEncodedDer', @sResult OUT, @encoding
```

Returns the binary DER in encoded string form. The `encoding` indicates the encoding and can be `base64`, `hex`, `uu`, `quoted-printable`, `base32`, or `modbase64`.

Returns `NULL` on failure

### Asn.GetLastSubItem

`Chilkat 11.7.0 · sqlserver · Asn · GetLastSubItem · method · since 9.5.0.49`

```sql
EXEC sp_OAMethod @asn, 'GetLastSubItem', @asn OUT  -- returns a ChilkatAsn object token
```

Returns the last ASN.1 sub-item. This method can be called immediately after any Append\* method to access the appended item.

Returns `NULL` on failure

### Asn.GetSubItem

`Chilkat 11.7.0 · sqlserver · Asn · GetSubItem · method · since 9.5.0.49`

```sql
EXEC sp_OAMethod @asn, 'GetSubItem', @asn OUT, @index  -- returns a ChilkatAsn object token
```

Returns the Nth ASN.1 sub-item. The 1st sub-item is at index 0.

Returns `NULL` on failure

### Asn.LoadAsnXml

`Chilkat 11.7.0 · sqlserver · Asn · LoadAsnXml · method · since 9.5.0.49`

```sql
EXEC sp_OAMethod @asn, 'LoadAsnXml', @success OUT, @xmlStr
```

Loads ASN.1 from the XML representation (such as that created by the AsnToXml method).

Returns 1 for success, 0 for failure.

### Asn.LoadBd

`Chilkat 11.7.0 · sqlserver · Asn · LoadBd · method · since 9.5.0.77`

```sql
EXEC sp_OAMethod @asn, 'LoadBd', @success OUT, @bd
```

Loads ASN.1 from the binary DER contained in `bd`.

Returns 1 for success, 0 for failure.

### Asn.LoadBinaryFile

`Chilkat 11.7.0 · sqlserver · Asn · LoadBinaryFile · method · since 9.5.0.49`

```sql
EXEC sp_OAMethod @asn, 'LoadBinaryFile', @success OUT, @path
```

Loads ASN.1 from a binary DER file.

Returns 1 for success, 0 for failure.

### Asn.LoadEncoded

`Chilkat 11.7.0 · sqlserver · Asn · LoadEncoded · method · since 9.5.0.49`

```sql
EXEC sp_OAMethod @asn, 'LoadEncoded', @success OUT, @asnContent, @encoding
```

Loads ASN.1 from an encoded string. The `encoding` can be `base64`, `hex`, `uu`, `quoted-printable`, `base32`, or `modbase64`.

Returns 1 for success, 0 for failure.

### Asn.SetEncodedContent

`Chilkat 11.7.0 · sqlserver · Asn · SetEncodedContent · method · since 9.5.0.49`

```sql
EXEC sp_OAMethod @asn, 'SetEncodedContent', @success OUT, @encodedBytes, @encoding
```

Sets the content of this primitive ASN.1 item. The `encoding` may be any of the following encodings: `Base64`, `Hex`, `Base58`, `modBase64`, `Base32`, `UU`, `QP` (for quoted-printable), `URL` (for url-encoding), `Q`, `B`, `url_oath`, `url_rfc1738`, `url_rfc2396`, and `url_rfc3986`. The `encoding` name is case insensitive (for example, both `Base64` and `base64` are treated the same).

Returns 1 for success, 0 for failure.

### Asn.WriteBd

`Chilkat 11.7.0 · sqlserver · Asn · WriteBd · method · since 9.5.0.77`

```sql
EXEC sp_OAMethod @asn, 'WriteBd', @success OUT, @bd
```

Appends the ASN.1 in binary DER format to `bd`.

Returns 1 for success, 0 for failure.

### Asn.WriteBinaryDer

`Chilkat 11.7.0 · sqlserver · Asn · WriteBinaryDer · method · since 9.5.0.49`

```sql
EXEC sp_OAMethod @asn, 'WriteBinaryDer', @success OUT, @path
```

Writes the ASN.1 in binary DER form to a file.

Returns 1 for success, 0 for failure.

## Related classes

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

