This documentation is archived and is not being maintained.

CAST Function

Exchange Server 2003

CAST Function

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Use the Structured Query Language (SQL) CAST Function to attribute a data type to a property in the returned recordset. Casting only supports Property Data Types.

Casting is optional and is primarily used for working with custom properties whose data type is not known by the Exchange store. The Exchange store recognizes all data types for the schema as installed by Microsoft Exchange Server 2003. Custom properties not cast are evaluated as string values. Casting Boolean properties is unnecessary.

Syntax

CAST(value AS datatype)

The value is either a property or a literal string.

The datatype is an XML data type. XML data types are case-sensitive.

Remarks

By using base-64 encoding, you can encode binary custom property values in a format that can be sent in XML. All Exchange Server 2003 binary properties are base-64 encoded by default. The following clause is an example where "a98k231KJg823kj" is a base-64 encoded string.

WHERE CAST("custom:mybinaryprop" AS "bin.base64") > "a98k231KJg823kj"

If you want to encode using bin.hex, casting must be repeated on the comparison value as shown in these examples:

WHERE CAST("custom:mybinaryprop" AS "bin.hex") = CAST("08AF183B82" as "bin.hex"
WHERE CAST("custom:myprop" AS "string") = CAST("08AF183B82" as "bin.hex")

Examples

WHERE CAST("custom:mydateprop" AS "dateTime") > "1998-02-01T10:00"
WHERE "custom:count" > CAST("0" AS "int")
WHERE "custom:creationdate" = CAST("1999-10-22T22:12:40.296Z" as "dateTime.tz")
WHERE "custom:price" > CAST("34.88" AS "fixed.14.4")

You can cast universally unique identifier (UUID) properties with or without the braces:

WHERE CAST("myguid" as "uuid") = "F04DA480-65B9-11d1-A29F-00AA00C14882"
WHERE CAST("myguid" as "uuid") = "{F04DA480-65B9-11d1-A29F-00AA00C14882}"
Show: