What is the idiomatic way to truncate a string down to 100 byte-pairs?
0
votes
1
answer
242
views
nvarchar(100)
holds 100 **byte-pairs**, as [documented here](https://learn.microsoft.com/en-us/sql/t-sql/data-types/nchar-and-nvarchar-transact-sql?view=sql-server-ver16#remarks) . LEFT([Your String], 100)
truncates your string down to 100 **characters** as [documented here](https://learn.microsoft.com/en-us/sql/t-sql/functions/left-transact-sql?view=sql-server-ver16) . These are not the same.
Foolishly, I have used LEFT([Your String], 100)
in the hopes of keeping [Your String]
within nvarchar(100)
. What are the idiomatic approaches to solving this problem correctly? I considered using CAST
, but I'm uncomfortable with implicitly truncating a string.
Asked by J. Mini
(1235 rep)
Jan 5, 2024, 07:21 PM
Last activity: Jan 7, 2024, 03:37 AM
Last activity: Jan 7, 2024, 03:37 AM