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/ado-net/configure-parameters.md
+12-1Lines changed: 12 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -72,11 +72,22 @@ The Microsoft SqlClient Data Provider for SQL Server type of a `Parameter` objec
72
72
||`StringFixedLength`|`NChar`|
73
73
||`Time`|`Time` in SQL Server 2008. Inferring a <xref:System.Data.SqlDbType> from `Time` isn't supported in versions of SQL Server earlier than SQL Server 2008.|
74
74
||`VarNumeric`|Inferring a <xref:System.Data.SqlDbType> from `VarNumeric` isn't supported.|
75
-
|user-defined type (an object with <xref:Microsoft.SqlServer.Server.SqlUserDefinedAggregateAttribute>|SqlClient always returns an Object|`SqlDbType.Udt` if <xref:Microsoft.SqlServer.Server.SqlUserDefinedTypeAttribute> is present, otherwise `Variant`|
75
+
|user-defined type (an object with <xref:Microsoft.SqlServer.Server.SqlUserDefinedAggregateAttribute>)|SqlClient always returns an Object|`SqlDbType.Udt` if <xref:Microsoft.SqlServer.Server.SqlUserDefinedTypeAttribute> is present, otherwise `Variant`|
> Conversions from decimal to other types are narrowing conversions that round the decimal value to the nearest integer value toward zero. If the result of the conversion isn't representable in the destination type, an <xref:System.OverflowException> is thrown.
79
81
82
+
> [!NOTE]
83
+
> **JSON**
84
+
>
85
+
> Set SqlDbType to Json when passing a parameter `Value` of type `string`. Otherwise SqlDbType defaults to `Nvarchar`.
86
+
>
87
+
> **Vector**
88
+
>
89
+
> For SQL vector datatype, a parameter `Value` of type `Microsoft.Data.SqlTypes.SqlVector<T>` must be specified. Parameter `Size` and vector dimension are inferred from the parameter `Value`. The parameter `Size` is ignored.
90
+
80
91
> [!NOTE]
81
92
> When you send a null parameter value to the server, you must specify <xref:System.DBNull>, not `null` (`Nothing` in Visual Basic). The null value in the system is an empty object that has no value. <xref:System.DBNull> is used to represent null values.
A native [JSON data type](../../../t-sql/data-types/json-data-type.md) is introduced in SQL Server 2025 and Azure SQL databases. This native JSON data type is available for structured JSON documents with automatic validation, efficient transport, and efficient storage.
17
+
18
+
The Microsoft.Data.SqlClient provider offers built-in support for JSON columns through:
19
+
- The common language runtime (CLR) `string` type for simple scenarios.
20
+
-`SqlJson` type for advanced use cases, such as client-side validation and explicit handling of JSON semantics.
21
+
- .NET 9 introduces a new SqlDbType.Json enumeration value for specifying JSON parameters. For earlier .NET versions, use `Microsoft.Data.SqlDbTypeExtensions`, which provides forward-compatible support for new SQL types.
22
+
- .NET 9 introduces a new `SqlDbType.Json` enumeration value for specifying JSON parameters.
23
+
- For earlier .NET versions, `Microsoft.Data.SqlDbTypeExtensions` is introduced as an alternative for `SqlDbType`.
24
+
25
+
## Example
26
+
27
+
The following example demonstrates the following scenarios to interact with JSON data.
28
+
29
+
- Insert a JSON value using CLR type `string`.
30
+
- Insert the JSON value using `SqlJson`. Using `SqlJson` is useful if you want to validate the JSON data before sending it to server.
SQL Server 2025 and Azure SQL Database introduce a native [Vector data type](../../../t-sql/data-types/vector-data-type.md) for storing fixed-dimension numeric embeddings with automatic validation and efficient binary storage. For backward compatibility, vectors are exposed as JSON arrays. Each element is float32 by default, and dimensions must range from 1 to 1998.
17
+
18
+
In .NET, the `Microsoft.Data.SqlClient` provider adds native vector handling through the <xref:Microsoft.Data.SqlTypes.SqlVector`1> class (for example, `SqlVector<float>`), using optimized binary transport over the Tabular Data Stream (TDS) protocol. Older clients can still pass vectors as JSON strings transparently.
19
+
20
+
The vector type enables similarity search and AI-driven scenarios, with server-side vector functions for efficient computation.
21
+
22
+
In SqlClient, `vector` data is exchanged with SQL Server using the <xref:Microsoft.Data.SqlTypes.SqlVector`1> class.
23
+
24
+
In newer .NET versions starting with version 10, a new `SqlDbType` enumeration value `Vector` is available for representing SQL parameters of type `vector`.
25
+
26
+
For earlier versions, use `Microsoft.Data.SqlDbTypeExtensions` to declare SQL parameters of type `vector`.
27
+
28
+
## Example
29
+
30
+
The following code sample demonstrates the following scenarios for a vector column of three dimensions.
31
+
32
+
- Insert non-null vectors using SqlParameter.
33
+
- Insert null vectors for a given vector column.
34
+
- Read a vector column.
35
+
- Use a stored procedure with a vector datatype parameter.
Streaming support between SQL Server and an application supports unstructured data on the server (documents, images, and media files). A SQL Server database can store binary large objects (BLOBs), but retrieving BLOBS can use a lot of memory.
18
+
Streaming support between SQL Server and an application supports unstructured data on the server (documents, images, and media files). A SQL Server database can store binary large objects (BLOBs), but retrieving BLOBS can use a large amount of memory.
19
19
20
20
Streaming support to and from SQL Server simplifies writing applications that stream data, without having to fully load the data into memory, resulting in fewer memory overflow exceptions.
21
21
22
-
Streaming support will also enable middle-tier applications to scale better, especially in scenarios where business objects connect to Azure SQL in order to send, retrieve, and manipulate large BLOBs.
22
+
Streaming support also enables middle-tier applications to scale better, especially in scenarios where business objects connect to Azure SQL in order to send, retrieve, and manipulate large BLOBs.
23
23
24
24
> [!WARNING]
25
-
> The members that support streaming are used to retrieve data from queries and to pass parameters to queries and stored procedures. The streaming feature addresses basic OLTP and data migration scenarios and is applicable to on-premises and off-premises data migrations environments.
25
+
> The members that support streaming are used to retrieve data from queries and to pass parameters to queries and stored procedures. The streaming feature addresses basic Online Transaction Processing (OLTP) and data migration scenarios and is applicable to on-premises and off-premises data migrations environments.
26
26
27
27
## Streaming support from SQL Server
28
28
@@ -55,31 +55,33 @@ The following members were added to <xref:System.Data.Common.DbDataReader> to en
55
55
Streaming support to SQL Server is in the <xref:Microsoft.Data.SqlClient.SqlParameter> class so it can accept and react to <xref:System.Xml.XmlReader>, <xref:System.IO.Stream>, and <xref:System.IO.TextReader> objects. <xref:Microsoft.Data.SqlClient.SqlParameter> is used to pass parameters to queries and stored procedures.
56
56
57
57
> [!NOTE]
58
-
> Disposing a <xref:Microsoft.Data.SqlClient.SqlCommand> object or calling <xref:Microsoft.Data.SqlClient.SqlCommand.Cancel%2A> must cancel any streaming operation. If an application sends <xref:System.Threading.CancellationToken>, cancellation is not guaranteed.
58
+
> Disposing a <xref:Microsoft.Data.SqlClient.SqlCommand> object or calling <xref:Microsoft.Data.SqlClient.SqlCommand.Cancel%2A> must cancel any streaming operation. If an application sends <xref:System.Threading.CancellationToken>, cancellation isn't guaranteed.
59
59
60
-
The following <xref:Microsoft.Data.SqlClient.SqlParameter.SqlDbType%2A> types will accept a <xref:Microsoft.Data.SqlClient.SqlParameter.Value%2A> of <xref:System.IO.Stream>:
60
+
The following <xref:Microsoft.Data.SqlClient.SqlParameter.SqlDbType%2A> types accept a <xref:Microsoft.Data.SqlClient.SqlParameter.Value%2A> of <xref:System.IO.Stream>:
61
61
62
-
-**Binary**
62
+
-`Binary`
63
63
64
-
-**VarBinary**
64
+
-`VarBinary`
65
65
66
-
The following <xref:Microsoft.Data.SqlClient.SqlParameter.SqlDbType%2A> types will accept a <xref:Microsoft.Data.SqlClient.SqlParameter.Value%2A> of <xref:System.IO.TextReader>:
66
+
The following <xref:Microsoft.Data.SqlClient.SqlParameter.SqlDbType%2A> types accept a <xref:Microsoft.Data.SqlClient.SqlParameter.Value%2A> of <xref:System.IO.TextReader>:
67
67
68
-
-**Char**
68
+
-`Char`
69
69
70
-
-**NChar**
70
+
-`NChar`
71
71
72
-
-**NVarChar**
72
+
-`NVarChar`
73
73
74
-
-**Xml**
74
+
-`Xml`
75
75
76
-
The **Xml**<xref:Microsoft.Data.SqlClient.SqlParameter.SqlDbType%2A> type will accept a <xref:Microsoft.Data.SqlClient.SqlParameter.Value%2A> of <xref:System.Xml.XmlReader>.
76
+
-`Json`
77
+
78
+
The **Xml**<xref:Microsoft.Data.SqlClient.SqlParameter.SqlDbType%2A> type accepts a <xref:Microsoft.Data.SqlClient.SqlParameter.Value%2A> of <xref:System.Xml.XmlReader>.
77
79
78
80
<xref:Microsoft.Data.SqlClient.SqlParameter.SqlValue%2A> can accept values of type <xref:System.Xml.XmlReader>, <xref:System.IO.TextReader>, and <xref:System.IO.Stream>.
79
81
80
-
The <xref:System.Xml.XmlReader>, <xref:System.IO.TextReader>, and <xref:System.IO.Stream> object will be transferred up to the value defined by the <xref:Microsoft.Data.SqlClient.SqlParameter.Size%2A>.
82
+
The <xref:System.Xml.XmlReader>, <xref:System.IO.TextReader>, and <xref:System.IO.Stream> object is transferred up to the value defined by the <xref:Microsoft.Data.SqlClient.SqlParameter.Size%2A>.
81
83
82
-
## Sample -- streaming from SQL Server
84
+
## Sample--streaming from SQL Server
83
85
84
86
Use the following Transact-SQL to create the sample database:
0 commit comments