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
Specified length '8000' is out of range. (Parameter 'maxLength')
Name: "Body"
dbType: NVarChar
maxLength: 8000
useServerDefault: false
isUniqueKey: false
columnSortOrder: -1
ILocale: 0
at Microsoft.SqlServer.Server.SqlMetaData.Construct(String name, SqlDbType dbType, Int64 maxLength, Boolean useServerDefault, Boolean isUniqueKey, SortOrder columnSortOrder, Int32 sortOrdinal) in E:\A\_work\65\s\corefx\src\System.Data.SqlClient\src\System\Data\Sql\SqlMetaData.cs:line 493
at Microsoft.SqlServer.Server.SqlMetaData..ctor(String name, SqlDbType dbType, Int64 maxLength) in E:\A\_work\65\s\corefx\src\System.Data.SqlClient\src\System\Data\Sql\SqlMetaData.cs:line 76
at Mtime.Messaging.Persistence.records@99.Invoke(ChatMessage m) in C:\Users\me\repos\app\Persistence.fs:line 102
It seems like there's a mismatch in talking bytes verses characters. If I understand correctly, nvarchar(n) accepts a max of 4,000 which refers to characters/'byte-pairs' or 8,000 bytes. It looks like the maxLength provided to SqlClient's Construct should be referring to byte-pairs (because of the maximum declared in the x_lServerMaxUnicode constant, but is actually referring to bytes.
If this is actually the problem, I'm have no idea where it's happening. Perhaps it's how the metadata is being queried?
The text was updated successfully, but these errors were encountered:
@smoothdeveloper thanks for the pointer.
It looks like sp_describe_first_result_set does declare max_length as specifically being the length is in bytes. sp_describe_undeclared_parameters has a suggested_max_length which refers to sys.column which also says the max_length is in bytes.
It seems like INFORMATION_SCHEMA.COLUMNS would have the right information in the column CHARACTER_MAXIMUM_LENGTH, but that might be a tonne of work to start using it in this type provider, if it's even possible. (I'm am both unfamiliar with SQL Server and Type Providers I'm afraid 😅)
nvarchar(max) does work and is a workaround for me, thank you.
Description
I get a
Specified length '8000' is out of range. (Parameter 'maxLength')
when trying to use a TVP with a column ofNVARCHAR(4000)
.Repro steps
Please provide the steps required to reproduce the problem
Expected behavior
Messages are inserted.
Actual behavior
Known workarounds
Drop the column size to 2000.
Related information
It's throwing on this line in SqlClient
and
x_lServerMaxUnicode
is set to 4000.It seems like there's a mismatch in talking bytes verses characters. If I understand correctly,
nvarchar(n)
accepts a max of 4,000 which refers to characters/'byte-pairs' or 8,000 bytes. It looks like themaxLength
provided to SqlClient'sConstruct
should be referring to byte-pairs (because of the maximum declared in thex_lServerMaxUnicode
constant, but is actually referring to bytes.If this is actually the problem, I'm have no idea where it's happening. Perhaps it's how the metadata is being queried?
The text was updated successfully, but these errors were encountered: