Skip to content

Commit bcc269a

Browse files
alansingfieldmairaw
andcommitted
SqlParameter - behaviour of Scale property for datetime2 parameters (#2604)
* Update SqlParameter.xml Added note about setting scale on datetime2, datetimeoffset and time parameters. It is not possible to set the scale to 0 as this gets changed to 7 internally. * Update xml/System.Data.SqlClient/SqlParameter.xml Oxford comma! Co-Authored-By: Maira Wenzel <[email protected]> * Update xml/System.Data.SqlClient/SqlParameter.xml Agreed Co-Authored-By: Maira Wenzel <[email protected]>
1 parent 8a2bc26 commit bcc269a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

xml/System.Data.SqlClient/SqlParameter.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,11 +1241,13 @@ static void CreateSqlParameterLocaleId(){
12411241
<format type="text/markdown"><![CDATA[
12421242
12431243
## Remarks
1244-
The <xref:System.Data.SqlClient.SqlParameter.Scale%2A> property is used by parameters that have a <xref:System.Data.SqlDbType> of `Decimal`.
1244+
The <xref:System.Data.SqlClient.SqlParameter.Scale%2A> property is used by parameters that have a <xref:System.Data.SqlDbType> of `Decimal`, `DateTime2`, `DateTimeOffset`, or `Time`.
12451245
12461246
> [!WARNING]
12471247
> Data may be truncated if the <xref:System.Data.SqlClient.SqlParameter.Scale%2A> property is not explicitly specified and the data on the server does not fit in scale 0 (the default).
1248-
1248+
> For the `DateTime2` type, scale 0 (the default) will be passed as datetime2(7). There is currently no way to send a parameter as datetime2(0). Scales 1-7 work as expected.
1249+
> This problem applies to `DateTimeOffset` and `Time` as well.
1250+
12491251
You do not need to specify values for the <xref:System.Data.SqlClient.SqlParameter.Precision%2A> and <xref:System.Data.SqlClient.SqlParameter.Scale%2A> properties for input parameters, as they can be inferred from the parameter value. `Precision` and `Scale` are required for output parameters and for scenarios where you need to specify complete metadata for a parameter without indicating a value, such as specifying a null value with a specific precision and scale.
12501252
12511253
> [!NOTE]

0 commit comments

Comments
 (0)