You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/connect/odbc/data-classification.md
+26-22Lines changed: 26 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
-
description: "Using Data Classification with Microsoft ODBC Driver for SQL Server"
3
-
title: "Using Data Classification with Microsoft ODBC Driver for SQL Server | Microsoft Docs"
2
+
description: Learn how to use Data Classification with the ODBC driver and how to incorporate your data protection policies into your ODBC application.
For the purpose of managing sensitive data, SQL Server and Azure SQL Server introduced the ability to provide database columns with sensitivity metadata that allows the client application to handle different types of sensitive data (such as health, financial, etc.) in accordance with data protection policies.
23
+
24
+
For managing sensitive data, SQL Server and Azure SQL Server introduced the ability to provide database columns with sensitivity metadata that allows the client application to handle different types of sensitive data (such as health, financial, etc.) in accordance with data protection policies.
23
25
24
26
For more information on how to assign classification to columns, see [SQL Data Discovery and Classification](../../relational-databases/security/sql-data-discovery-and-classification.md).
25
27
26
28
Microsoft ODBC Driver 17.2 allows the retrieval of this metadata via SQLGetDescField using the SQL_CA_SS_DATA_CLASSIFICATION field identifier.
27
29
28
30
## Format
31
+
29
32
SQLGetDescField has the following syntax:
30
33
31
-
```
34
+
```cpp
32
35
SQLRETURN SQLGetDescField(
33
36
SQLHDESC DescriptorHandle,
34
37
SQLSMALLINT RecNumber,
@@ -37,8 +40,9 @@ SQLRETURN SQLGetDescField(
37
40
SQLINTEGER BufferLength,
38
41
SQLINTEGER * StringLengthPtr);
39
42
```
43
+
40
44
*DescriptorHandle*
41
-
[Input] IRD(Implementation Row Descriptor) handle. Can be retrieved by a call to SQLGetStmtAttr with SQL_ATTR_IMP_ROW_DESC statement attribute
45
+
[Input] IRD(Implementation Row Descriptor) handle. Can be retrieved by a call to SQLGetStmtAttr with SQL_ATTR_IMP_ROW_DESC statement attribute
42
46
43
47
*RecNumber*
44
48
[Input] 0
@@ -54,11 +58,11 @@ SQLRETURN SQLGetDescField(
54
58
55
59
*StringLengthPtr*
56
60
[Output] Pointer to the buffer in which to return the total number of bytes available to return in *ValuePtr*.
57
-
61
+
58
62
> [!NOTE]
59
63
> If the size of the buffer is unknown, it can be determined by calling SQLGetDescField with *ValuePtr* as NULL and examining the value of *StringLengthPtr*.
60
-
61
-
If Data Classification information is not available, an *Invalid Descriptor Field* error will be returned.
64
+
65
+
If Data Classification information isn't available, an *Invalid Descriptor Field* error will be returned.
62
66
63
67
Upon a successful call to SQLGetDescField, the buffer pointed to by *ValuePtr* will contain the following data:
64
68
@@ -83,11 +87,10 @@ s - index into the *`sensitivitylabels`* array, `FF FF` if not labeled
83
87
84
88
t - index into the *`informationtypes`* array, `FF FF` if not labeled
85
89
86
-
87
90
<br><br>
88
91
The format of the data can be expressed as the following pseudo-structures:
89
92
90
-
```
93
+
```cpp
91
94
struct IDnamePair {
92
95
BYTE nameLen;
93
96
USHORT name[nameLen];
@@ -111,11 +114,11 @@ struct {
111
114
} columnClassification[nColumns];
112
115
```
113
116
114
-
115
117
## Code sample
118
+
116
119
Test application that demonstrates how to read Data Classification metadata. On Windows it can be compiled using `cl /MD dataclassification.c /I (directory of msodbcsql.h) /link odbc32.lib` and run with a connection string, and a SQL query (that returns classified columns) as parameters:
117
120
118
-
```
121
+
```cpp
119
122
#ifdef _WIN32
120
123
#include <windows.h>
121
124
#endif
@@ -240,22 +243,23 @@ int main(int argc, char **argv)
240
243
```
241
244
242
245
## <a name="bkmk-version"></a>Supported Version
243
-
Microsoft ODBC Driver 17.2 allows the retrieval of Data Classification information via `SQLGetDescField` if `FieldIdentifier` is set to `SQL_CA_SS_DATA_CLASSIFICATION` (1237).
244
246
245
-
Starting from Microsoft ODBC Driver 17.4.1.1 it is possible to retrieve version of Data Classification supported by a server via `SQLGetDescField`using the `SQL_CA_SS_DATA_CLASSIFICATION_VERSION` (1238) field identifier. In 17.4.1.1 the supported data classification version is set to "2".
247
+
Microsoft ODBC Driver 17.2 allows the retrieval of Data Classification information via `SQLGetDescField` if `FieldIdentifier` is set to `SQL_CA_SS_DATA_CLASSIFICATION` (1237).
246
248
247
-
249
+
Starting from Microsoft ODBC Driver 17.4.1.1, it's possible to retrieve the version of Data Classification supported by a server via `SQLGetDescField` using the `SQL_CA_SS_DATA_CLASSIFICATION_VERSION` (1238) field identifier. In 17.4.1.1, the supported data classification version is set to "2".
248
250
249
-
Starting from 17.4.2.1 introduced the default version of data classification which is set to "1" and is the version driver is reporting to SQL Server as supported. New connection attribute `SQL_COPT_SS_DATACLASSIFICATION_VERSION` (1400) can allow application to change the supported version of Data Classification from "1" up to maximum supported.
251
+
Starting from 17.4.2.1, the default version of data classification is set to "1" and is the version the driver reports to SQL Server as supported. A new connection attribute `SQL_COPT_SS_DATACLASSIFICATION_VERSION` (1400) can allow application to change the supported version of Data Classification from "1" up to the maximum supported.
250
252
251
-
Example:
253
+
Example:
252
254
253
-
To set the version this call should be made right before the SQLConnect or SQLDriverConnect call:
254
-
```
255
+
To set the version, this call should be made right before the SQLConnect or SQLDriverConnect call:
256
+
257
+
```cpp
255
258
ret = SQLSetConnectAttr(dbc, SQL_COPT_SS_DATACLASSIFICATION_VERSION, (SQLPOINTER)2, SQL_IS_INTEGER);
256
259
```
257
260
258
-
The value of the currently supported version of Data Classification can be retrieved via SQLGetConnectAttr call:
259
-
```
261
+
The value of the currently supported version of Data Classification can be retrieved via SQLGetConnectAttr call:
262
+
263
+
```cpp
260
264
ret = SQLGetConnectAttr(dbc, SQL_COPT_SS_DATACLASSIFICATION_VERSION, (SQLPOINTER)&dataClassVersion, SQL_IS_INTEGER, 0);
0 commit comments