Home
%3CLINGO-SUB%20id%3D%22lingo-sub-757748%22%20slang%3D%22en-US%22%3EIntroducing%20UTF-8%20support%20for%20Azure%20SQL%20Database%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-757748%22%20slang%3D%22en-US%22%3E%3CP%3EUTF-8%20support%20is%20now%20in%20preview%20for%20Azure%20SQL%20Database%2C%20allowing%20more%20options%20to%20companies%20extending%20their%20businesses%20to%20a%20global%20scale%2C%20where%20the%20requirement%20of%20providing%20global%20multilingual%20database%20applications%20and%20services%20is%20critical%20to%20meet%20customer%20demands%2C%20and%20specific%20market%20regulations.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%225%22%3E%3CSTRONG%3EHow%20is%20it%20implemented%3F%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3ETo%20limit%20the%20amount%20of%20changes%20required%20for%20the%20above%20scenarios%2C%20UTF-8%20is%20enabled%20in%20existing%20the%20data%20types%20CHAR%20and%20VARCHAR.%20String%20data%20is%20automatically%20encoded%20to%20UTF-8%20when%20creating%20or%20changing%20an%20object%E2%80%99s%20collation%20to%20a%20collation%20with%20the%20%E2%80%9C_UTF8%E2%80%9D%20suffix%2C%20for%20example%20from%20%3CSTRONG%3ELATIN1_GENERAL_100_CI_AS_SC%3C%2FSTRONG%3E%20to%20%3CSTRONG%3ELATIN1_GENERAL_100_CI_AS_SC_UTF8%3C%2FSTRONG%3E.%20Refer%20to%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fsql%2Frelational-databases%2Fcollations%2Fset-or-change-the-database-collation%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ESet%20or%20Change%20the%20Database%20Collation%3C%2FA%3E%20and%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fsql%2Frelational-databases%2Fcollations%2Fset-or-change-the-column-collation%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ESet%20or%20Change%20the%20Column%20Collation%3C%2FA%3E%20for%20more%20details%20on%20how%20to%20perform%20those%20changes.%20Note%20that%20NCHAR%20and%20NVARCHAR%20remains%20unchanged%20and%20allows%20UCS-2%2FUTF-16%20encoding.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20see%20all%20available%20UTF-8%20collations%20by%20executing%20the%20following%20command%20in%20your%20SQL%20Database%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3ESELECT%20Name%2C%20Description%20FROM%20fn_helpcollations()%0AWHERE%20Name%20LIKE%20'%25UTF8'%3B%3C%2FPRE%3E%0A%3CP%3E%3CSTRONG%3EFunctional%20comparison%20between%20UTF-8%20and%20UTF-16%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EUTF-8%20and%20UTF-16%20both%20handle%20the%20same%20Unicode%20characters%2C%20and%20both%20are%20variable%20length%20encodings%20that%20require%20up%20to%2032%20bits%20per%20character.%20However%2C%20there%20are%20important%20differences%20that%20drive%20the%20choice%20of%20whether%20to%20use%20UTF-8%20or%20UTF-16%20in%20your%20multilingual%20database%20or%20column%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%20style%3D%22font-weight%3A%20400%3B%22%3EUTF-8%20encodes%20the%20common%20ASCII%20characters%20including%20English%20and%20numbers%20using%208-bits.%20ASCII%20characters%20(0-127)%20use%201%20byte%2C%20code%20points%20128%20to%202047%20use%202%20bytes%2C%20and%20code%20points%202048%20to%2065535%20use%203%20bytes.%20The%20code%20points%2065536%20to%201114111%20use%26nbsp%3B%204%20bytes%2C%20and%20represent%20the%20character%20range%20for%20Supplementary%20Characters.%3C%2FLI%3E%0A%3CLI%20style%3D%22font-weight%3A%20400%3B%22%3EBut%26nbsp%3BUTF-16%20uses%20at%20least%2016-bits%20for%20every%20character%20in%20code%20points%200%20to%2065535%20(available%20in%20UCS-2%20and%20UTF-16%20alike)%2C%20and%20code%20points%2065536%20to%201114111%20use%20the%20same%204%20bytes%20as%20UTF-8.%26nbsp%3B%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EThe%20table%20below%20outlines%20these%20storage%20boundaries%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CTABLE%3E%0A%3CTHEAD%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3E%3CSTRONG%3ECode%20Range%20(hexadecimal)%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E%3CSTRONG%3ECode%20Range%20(decimal)%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E%3CSTRONG%3EStorage%20bytes%20with%20UTF-8%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E%3CSTRONG%3EStorage%20bytes%20with%20UTF-16%3C%2FSTRONG%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTHEAD%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3E000000%20%E2%80%93%2000007F%20(ASCII)%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E0%20-%20127%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E1%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E2%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3E000080%20%E2%80%93%2000009F%3CBR%20%2F%3E0000A0%20%E2%80%93%200003FF%3CBR%20%2F%3E000400%20%E2%80%93%200007FF%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E128%20%E2%80%93%20159%3CBR%20%2F%3E160%20%E2%80%93%201%2C023%3CBR%20%2F%3E1%2C024%20%E2%80%93%202%2C047%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E2%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E2%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3E000800%20%E2%80%93%20003FFF%3CBR%20%2F%3E004000%20%E2%80%93%2000FFFF%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E2%2C048%20-%2016%2C383%3CBR%20%2F%3E16%2C384%20%E2%80%93%2065%2C535%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E3%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E2%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3E%0A%3CP%3E010000%20%E2%80%93%2003FFFF%3CBR%20%2F%3E040000%20%E2%80%93%2010FFFF%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E65%2C536%20%E2%80%93%20262%2C143%3CBR%20%2F%3E262%2C144%20%E2%80%93%201%2C114%2C111%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E4%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%3E%0A%3CP%3E4%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%225%22%3E%3CSTRONG%3EConsiderations%20for%20choosing%20UTF-8%20or%20UTF-16%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3EIf%20your%20%3CSTRONG%3Edataset%20uses%20primarily%20ASCII%20characters%3C%2FSTRONG%3E%20(which%20represent%20majority%20of%20Latin%20alphabets)%2C%20significant%20storage%20savings%20may%20be%20achieved%20as%20compared%20to%20UTF-16%20data%20types.%3C%2FP%3E%0A%3CP%3EFor%20example%2C%20changing%20an%20existing%20column%20data%20type%20from%20NCHAR(10)%20to%20CHAR(10)%20using%20an%20UTF-8%20enabled%20collation%2C%20translates%20into%20nearly%2050%25%20reduction%20in%20storage%20requirements.%20This%20is%20because%20NCHAR(10)%20requires%2022%20bytes%20for%20storage%2C%20whereas%20CHAR(10)%20requires%2012%20bytes%20for%20the%20same%20Unicode%20string.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhat%20if%20your%20%3CSTRONG%3Edataset%20is%20not%20predominately%20ASCII%3C%2FSTRONG%3E%3F%26nbsp%3BAbove%20the%20ASCII%20range%2C%20almost%20all%20Latin%20alphabets%2C%20but%20also%20Greek%2C%20Cyrillic%2C%20Coptic%2C%20Armenian%2C%20Hebrew%2C%20Arabic%2C%20Syriac%2C%20T%C4%81na%20and%20N%E2%80%99Ko%20will%20use%202%20bytes%20per%20character%20in%20both%20UTF-8%20and%20UTF-16%20(128%20to%202047).%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBut%20Chinese%2C%20Japanese%2C%20or%20Korean%20characters%20are%20represented%20starting%20in%20the%20range%202048%20to%2065535%2C%20and%20use%203%20bytes%20in%20UTF-8%2C%20but%20only%202%20bytes%20in%20UTF-16.%20If%20your%20dataset%20is%20mostly%20in%20this%20character%20range%20then%20using%20UTF-16%20is%20preferred.%20%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20the%20Supplementary%20character%20range%20(65536%20to%201114111)%20there%20is%20no%20measurable%20difference%20between%20UTF-8%20and%20UTF-16%20encoding.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20read%20more%20about%20Unicode%20support%20in%20SQL%20Database%2C%20including%20details%20on%20UTF-8%20support%2C%20see%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fsql%2Frelational-databases%2Fcollations%2Fcollation-and-unicode-support%23Unicode_Defn%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EHow%20to%20convert%20to%20UTF-8%3F%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3ETwo%20methods%20to%20convert%20data%20are%20described%20next.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E1)%20%3CSTRONG%3EConvert%20column%20data%3C%2FSTRONG%3E.%20Imagine%20you%20have%20a%20current%20table%20that%20is%20encoded%20in%20UCS-2%2FUTF-16%20(depends%20on%20whether%20a%20supplementary%20character%20enabled%20collation%20is%20used)%20or%20non-Unicode%2C%20like%20the%20following%20examples%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3ECREATE%20TABLE%20dbo.MyTable%20(MyString%20NVARCHAR(50)%20COLLATE%20Latin1_General_100_CI_AI_SC)%3B%0ACREATE%20TABLE%20dbo.MyTable%20(MyString%20VARCHAR(50)%20COLLATE%20Latin1_General_100_CI_AI)%3B%3C%2FPRE%3E%0A%3CP%3ETo%20convert%20it%20in-place%2C%20run%20an%20alter%20statement%2C%20like%20the%20following%20example%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3EALTER%20TABLE%20dbo.MyTable%0AALTER%20COLUMN%20MyString%20VARCHAR(50)%20COLLATE%20Latin1_General_100_CI_AI_SC_UTF8%3C%2FPRE%3E%0A%3CP%3EIt's%20very%20easy%20to%20implement%2C%20however%20this%20is%20a%20possibly%20blocking%20operation%20which%20may%20pose%20an%20issue%20for%20large%20tables%20and%20busy%20applications.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E2)%20%3CSTRONG%3ECopy%20and%20Replace%3C%2FSTRONG%3E.%20This%20method%20involves%20copying%20data%20to%20a%20new%20table%20where%20the%20target%20column(s)%20are%20already%20in%20UTF-8%2C%20and%20then%20replace%20the%20old%20table.%20The%20following%20T-SQL%20example%20illustrates%20this%20using%20the%20second%20example%20table%20above%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3ECREATE%20TABLE%20dbo.MyTable2%20(VARCHAR(50)%20COLLATE%20Latin1_General_100_CI_AI_SC_UTF8)%3B%0AINSERT%20INTO%20dbo.MyTable2%0ASELECT%20*%20FROM%20dbo.MyTable%3B%0ADROP%20TABLE%20dbo.MyTable%3B%0AEXEC%20sp_rename%20'dbo.MyTable2'%2C%20'dbo.MyTable%E2%80%99%3B%3C%2FPRE%3E%0A%3CP%3EThis%20method%20is%20much%20faster%2C%20but%20handling%20complex%20schemas%20with%20many%20dependencies%20(FKs%2C%20PKs%2C%20Triggers%2C%20DFs)%20and%20tail%20of%20the%20table%20synch%20requires%20much%20more%20preparation.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20conclusion%2C%20keep%20the%20topics%20discussed%20here%20in%20mind%20when%20choosing%20what%20encoding%20to%20use%20in%20your%20database%20or%20columns.%20Especially%20in%20terms%20of%20what%20is%20the%20predominant%20language%2Fcharacter%20set%20that's%20expected%20to%20store%20in%20a%20specific%20table%20column.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPedro%20Lopes%20(%20%3CA%20href%3D%22https%3A%2F%2Ftwitter.com%2FSQLPedro%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%40SQLPedro%20%3C%2FA%3E)%20%E2%80%93%20Senior%20Program%20Manager%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-757748%22%20slang%3D%22en-US%22%3E%3CP%20style%3D%22box-sizing%3A%20border-box%3B%20color%3A%20%23333333%3B%20font-family%3A%20inherit%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20line-height%3A%201.7142%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%20margin%3A%200px%3B%22%3E%3CSPAN%20style%3D%22box-sizing%3A%20border-box%3B%20font-family%3A%20%26amp%3Bquot%3B%22%3EUTF-8%20support%20is%20now%20in%20preview%20for%20Azure%20SQL%20Database%2C%20allowing%20more%20options%20to%20companies%20extending%20their%20businesses%20to%20a%20global%20scale%2C%20where%20the%20requirement%20of%20providing%20global%20multilingual%20database%20applications%20and%20services%20is%20critical%20to%20meet%20customer%20demands%2C%20and%20specific%20market%20regulations%3C%2FSPAN%3E.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-SUB%20id%3D%22lingo-sub-770259%22%20slang%3D%22en-US%22%3ERe%3A%20Introducing%20UTF-8%20support%20for%20Azure%20SQL%20Database%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-770259%22%20slang%3D%22en-US%22%3E%3CP%3EPedro%2C%20this%20is%20very%20helpful%20in%20terms%20of%20picking%20UTF-8%20vs.%20UTF-16%2C%20but%20doesn't%20mention%20why%20I%20might%20want%20UTF%20at%20all%20when%20all%20my%20applications%20that%20use%20NVARCHAR%20work%20fine%20using%20the%20SQL_Latin1_General_CP1_CI_AS%20collation%2C%20and%20I'm%20interested%20in%20learning%20about%20that.%20Thanks!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-770406%22%20slang%3D%22en-US%22%3ERe%3A%20Introducing%20UTF-8%20support%20for%20Azure%20SQL%20Database%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-770406%22%20slang%3D%22en-US%22%3E%3CP%3EIf%20you%20are%20working%20with%20NVARCHAR%20in%20that%20collation%2C%20then%20you're%20using%20UCS-2%20encoding%20that%20can%20represent%20the%20first%2065535%20Unicode%20characters.%20Like%20I%20started%20by%20saying%2C%20if%20you%20have%20a%20%3CSPAN%20style%3D%22display%3A%20inline%20!important%3B%20float%3A%20none%3B%20background-color%3A%20%23ffffff%3B%20color%3A%20%23333333%3B%20font-family%3A%20'SegoeUI'%2C'Lato'%2C'Helvetica%20Neue'%2CHelvetica%2CArial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3Erequirement%20of%20providing%20global%20multilingual%20database%20applications%20and%20services%2C%20then%20you%20likely%20need%20full%20Unicode%20support.%20Same%20to%20meet%20some%20specific%20market%2Findustry%20regulations.%20%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20style%3D%22display%3A%20inline%20!important%3B%20float%3A%20none%3B%20background-color%3A%20%23ffffff%3B%20color%3A%20%23333333%3B%20font-family%3A%20'SegoeUI'%2C'Lato'%2C'Helvetica%20Neue'%2CHelvetica%2CArial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3EAfter%20you%20set%20that%20you%20do%20have%20a%20requirement%20to%20use%20Unicode%2C%20then%20choosing%20whether%20to%20use%20UTF-8%20or%20UTF-16%20falls%20into%20the%20several%20considerations%20explained%20in%20this%20blog%2C%20and%20also%20in%20the%20documentation%20at%26nbsp%3B%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%22%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Frelational-databases%2Fcollations%2Fcollation-and-unicode-support%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Frelational-databases%2Fcollations%2Fcollation-and-unicode-support%3C%2FA%3E%3C%2FFONT%3E.%20Hope%20this%20helps.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-770716%22%20slang%3D%22en-US%22%3ERe%3A%20Introducing%20UTF-8%20support%20for%20Azure%20SQL%20Database%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-770716%22%20slang%3D%22en-US%22%3E%3CP%3EAwesome%20news!%3C%2FP%3E%0A%3CP%3EThanks%20for%20sharing%26nbsp%3B%3CSPAN%3EPedro%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-770771%22%20slang%3D%22en-US%22%3ERe%3A%20Introducing%20UTF-8%20support%20for%20Azure%20SQL%20Database%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-770771%22%20slang%3D%22en-US%22%3E%3CP%3EI%20updated%20the%20message.%20I%20mistakenly%20added%20link%20to%20a%20different%20lecture.%20Now%20the%20link%20to%20the%20download%20is%20correct%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-770762%22%20slang%3D%22en-US%22%3ERe%3A%20Introducing%20UTF-8%20support%20for%20Azure%20SQL%20Database%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-770762%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F380947%22%20target%3D%22_blank%22%3E%40m60freeman%3C%2FA%3E%26nbsp%3B%2C%20There%20are%20plenty%20of%20reasons%20why%20people%20should%20(and%20will)%20use%20UTF-8.%20%3CSTRONG%3EThe%20size%20of%20the%20stored%20data%20is%20only%20one%20of%20the%20parameters%2C%20and%20not%20necessarily%20the%20most%20important!%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20download%20the%20session's%20materials%20from%20my%20lecture%20at%26nbsp%3Bsqlsaturday%20here%3A%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgallery.technet.microsoft.com%2FUTF-8-in-SQL-Server-2019-8d97cca2%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgallery.technet.microsoft.com%2FUTF-8-in-SQL-Server-2019-8d97cca2%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EGo%20over%20the%20presentation%20file%3A%20You%20can%20notice%20that%20I%20split%20the%20discussion%20into%20three%20levels%20(1)%20developers%2C%20(2)%20DBA%2C%20(3)%20Internals%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFrom%20the%20DBA%20point%20of%20view%20we%20discuss%20the%20%3CU%3E%3CSTRONG%3Esize%3C%2FSTRONG%3E%3C%2FU%3Eand%20%3CU%3E%3CSTRONG%3Eperformance%3C%2FSTRONG%3E%3C%2FU%3E%2C%20but%20from%20the%20developers%20point%20of%20view%20there%20is%20a%20huge%20advantage%20related%20to%20%22%3CU%3E%3CSTRONG%3Ecompatibility%3C%2FSTRONG%3E%3C%2FU%3E%22%20which%20can%20be%20much%20more%20important%20than%20%22size%22%20in%20some%20cases.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20cannot%20give%2075%20minutes%20lecture%20in%20one%20message%20in%20the%20forum%20but%20in%20VERY%20VERY%20VERY%20short%20(slides%2021%2B25%20in%20the%20presentation%20file%20summarize%20all%20in%20two%20tables)%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26gt%3B%20%3CU%3E%3CSTRONG%3ESize%3C%2FSTRONG%3E%3C%2FU%3E%3A%20as%20Pedro%20explained%20in%20some%20ranges%20of%20code%20points%20the%20UTF-8%20is%20smaller%20then%20UTF-16%2C%20but%20even%20if%20you%20use%20non-English%20languages%2C%20then%20this%20might%20give%20you%20extreme%20advantage.%3C%2FP%3E%0A%3CP%3EFor%20example%20think%20about%20Hebrew%20forum%20(or%20Hebrew%20message%20in%20this%20forum)%2C%20and%20let's%20assume%20I%20simply%20write%20my%20name%20in%20the%20message(this%20is%20my%20real%20name%20in%20Hebrew)%3A%3C%2FP%3E%0A%3CP%3E%D7%A8%D7%95%D7%A0%D7%9F%D7%90%D7%A8%D7%99%D7%90%D7%9C%D7%99.%3C%2FP%3E%0A%3CP%3Ebut...%20Hebrew%20is%20written%20from%20%3CU%3ERTL%3C%2FU%3E(in%20the%20above%20text%20the%20dot%20is%20not%20in%20the%20right%20place!%20In%20RTL%20language%20the%20Dot%20should%20be%20on%20the%20left%20side)%2C%20and%20I%20need%20to%20move%20the%20text%20to%20the%20right%20side%20of%20the%20page%20as%20well.%20In%20addition%2C%20I%20like%20myself%20so%20I%20make%20my%20name%20in%20bold%2C%20and%20I%20am%20so%20happy%20that%20this%20feature%20finally%20supported%20in%20Azure%20so%20I%20add%20some%20coolers%20to%20celebrate.%20The%20result%20will%20look%20like%20bellow%20text%3A%3C%2FP%3E%0A%3CP%20style%3D%22direction%3A%20rtl%3B%20text-align%3A%20right%3B%22%3E%3CSTRONG%3E%3CSPAN%20style%3D%22background-color%3A%20%23ffff99%3B%20color%3A%20%23339966%3B%22%3E%D7%A8%3C%2FSPAN%3E%3CSPAN%20style%3D%22background-color%3A%20%2300ff00%3B%20color%3A%20%23ff0000%3B%22%3E%D7%95%3C%2FSPAN%3E%3CSPAN%20style%3D%22background-color%3A%20%230000ff%3B%22%3E%D7%A0%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20%23ff99cc%3B%22%3E%D7%9F%3C%2FSPAN%3E%3CSPAN%20style%3D%22background-color%3A%20%23000000%3B%20color%3A%20%23ccffcc%3B%22%3E%D7%90%3C%2FSPAN%3E%3CSPAN%20style%3D%22background-color%3A%20%23ff99cc%3B%20color%3A%20%23000080%3B%22%3E%D7%A8%3C%2FSPAN%3E%3CSPAN%20style%3D%22background-color%3A%20%23808080%3B%20color%3A%20%23ff00ff%3B%22%3E%D7%99%3C%2FSPAN%3E%3CSPAN%20style%3D%22background-color%3A%20%23ffffff%3B%20color%3A%20%23993300%3B%22%3E%D7%90%3C%2FSPAN%3E%3CSPAN%20style%3D%22background-color%3A%20%23003300%3B%20color%3A%20%23ffcc99%3B%22%3E%D7%9C%3C%2FSPAN%3E%3CSPAN%20style%3D%22background-color%3A%20%23ccffcc%3B%20color%3A%20%23993300%3B%22%3E%D7%99%3CSPAN%20style%3D%22background-color%3A%20%23333300%3B%20color%3A%20%23ffffff%3B%22%3E.%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThe%20end-user%20only%20sees%20Hebrew%20letters.%20Therefore%2C%20he%20might%20say%20that%20UTF-8%20will%20not%20give%20him%20smaller%20size%20since%20Hebrew%20is%20the%20range%20of%20128-2047%26nbsp%3Band%20in%20this%20rage%20UTF-8%20has%20the%20same%20size%20as%20UTF-16.%20Moreover%2C%20we%20can%20do%20the%20same%20example%20with%26nbsp%3BChinese%2C%20Japanese%20or%20Korean%20-%20in%20this%20case%20the%20poor%20clients%20might%20say%20that%20soince%20the%20text%20in%20Chinese%2C%20Japanese%20or%20Korean%20then%20it%20is%20in%20the%20range%20of%202048%20%E2%80%93%2065535%20which%20mean%20the%20size%20will%20be%201.5%20bigger%20in%20UTF-8!%20%3CSTRONG%3EAre%20these%20arguments%20correct%3F!%3F%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThe%20data%20in%20the%20database%20does%20not%20includes%20plain%20text%2C%20but%20all%20the%20HTML%2FCSS%20code%20behind%20the%20scene%20as%20well!%3C%2FP%3E%0A%3CP%3EThe%20fact%20is%20that%20for%20this%20simple%20short%20name%26nbsp%3B%3CSTRONG%3Ethe%20server%20actually%20stores%20the%20following%20code!%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%26lt%3Bp%20style%3D%22direction%3A%20rtl%3B%22%26gt%3B%0A%20%20%20%20%26lt%3Bstrong%26gt%3B%0A%20%20%20%20%20%20%20%20%26lt%3Bspan%20style%3D%22background-color%3A%20%23ffff99%3B%20color%3A%20%23339966%3B%22%26gt%3B%D7%A8%26lt%3B%2Fspan%26gt%3B%0A%20%20%20%20%20%20%20%20%26lt%3Bspan%20style%3D%22background-color%3A%20%2300ff00%3B%20color%3A%20%23ff0000%3B%22%26gt%3B%D7%95%26lt%3B%2Fspan%26gt%3B%0A%20%20%20%20%20%20%20%20%26lt%3Bspan%20style%3D%22background-color%3A%20%230000ff%3B%20color%3A%20%23ffffff%3B%22%26gt%3B%D7%A0%26lt%3B%2Fspan%26gt%3B%0A%20%20%20%20%20%20%20%20%26lt%3Bspan%20style%3D%22background-color%3A%20%23808080%3B%20color%3A%20%23ff99cc%3B%22%26gt%3B%D7%9F%26lt%3B%2Fspan%26gt%3B%20%0A%20%20%20%20%20%20%20%20%26lt%3Bspan%20style%3D%22background-color%3A%20%23000000%3B%20color%3A%20%23ccffcc%3B%22%26gt%3B%D7%90%26lt%3B%2Fspan%26gt%3B%0A%20%20%20%20%20%20%20%20%26lt%3Bspan%20style%3D%22background-color%3A%20%23ff99cc%3B%20color%3A%20%23000080%3B%22%26gt%3B%D7%A8%26lt%3B%2Fspan%26gt%3B%0A%20%20%20%20%20%20%20%20%26lt%3Bspan%20style%3D%22background-color%3A%20%23808080%3B%20color%3A%20%23ff00ff%3B%22%26gt%3B%D7%99%26lt%3B%2Fspan%26gt%3B%0A%20%20%20%20%20%20%20%20%26lt%3Bspan%20style%3D%22background-color%3A%20%23ffffff%3B%20color%3A%20%23993300%3B%22%26gt%3B%D7%90%26lt%3B%2Fspan%26gt%3B%0A%20%20%20%20%20%20%20%20%26lt%3Bspan%20style%3D%22background-color%3A%20%23003300%3B%20color%3A%20%23ffcc99%3B%22%26gt%3B%D7%9C%26lt%3B%2Fspan%26gt%3B%0A%20%20%20%20%20%20%20%20%26lt%3Bspan%20style%3D%22background-color%3A%20%23ccffcc%3B%20color%3A%20%23993300%3B%22%26gt%3B%D7%99%26lt%3B%2Fspan%26gt%3B%0A%20%20%20%20%20%20%20%20%26lt%3Bspan%20style%3D%22background-color%3A%20%23333300%3B%20color%3A%20%23ffffff%3B%22%26gt%3B.%26lt%3B%2Fspan%26gt%3B%0A%20%20%20%20%26lt%3B%2Fstrong%26gt%3B%0A%26lt%3B%2Fp%26gt%3B%3C%2FPRE%3E%0A%3CP%3EThis%20code%20includes%20%3CSTRONG%3E898%20characters%3C%2FSTRONG%3E%2C%20and%20only%20%3CSTRONG%3E10%20of%20these%20are%20in%20Hebrew%3C%2FSTRONG%3E%2C%20while%20the%20rest%20are%20in%20ASCII%20range!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20means%20that%20using%20NVARCHAR%20we%20use%20(898*2)%20%3D%20%3CSTRONG%3E1796%20bytes%3C%2FSTRONG%3E%2C%20but%20using%20UTF-8%20we%20will%20use%20only%20(888*1)%2B(10*3)%20%3D%20%3CSTRONG%3E918%20bytes!%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3ETherefore%2C%20even%20for%20Non-English%20languages%20we%20might%20want%20to%20use%20UTF-8%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26gt%3B%20%3CU%3E%3CSTRONG%3EPerformance%3C%2FSTRONG%3E%3C%2FU%3E%3A%20Size%20directly%20related%20to%20memory%20and%20IO%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26gt%3B%20%3CU%3E%3CSTRONG%3Ecompatibility%3C%2FSTRONG%3E%3C%2FU%3E%3A%20There%20are%20two%20aspects%20of%26nbsp%3Bcompatibility!%20(1)%26nbsp%3Bcompatibility%20inside%20the%20server%20between%20different%20values.%20(2)%26nbsp%3Bcompatibility%20to%20external%20applications%2C%20Operating%20systems%20and%20so%20on%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E(1)%26nbsp%3Bcompatibility%20inside%20the%20server%3A%20NVARCHAR%20data%20type%20is%20not%20fully%20compatible%20with%20VARCHAR%20and%20using%20combination%20of%20text%20in%20NVARCHAR%20with%20text%20in%20VARCHAR%20you%20might%20get%20a%20very%20strange%20and%20unexpected%20result%20(at%20least%20unexpected%20by%20most%20users).%20The%20entire%20idea%20that%20we%20have%20to%20use%20two%20different%20types%20of%20data%20(%3CU%3ENational%20charter%20types%3C%2FU%3Elike%20VARCHAR%2C%20NCHAR%2C%20XML%20and%20%3CU%3ENon-National%20charter%20types%3C%2FU%3Elike%20CHAR%2C%20VARCHAR)%20is%20a%20base%20for%20multiple%20issues%20and%20performance%20related%20to%20converting%20the%20types%20behind%20the%20scene.%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%230000FF%22%3EAs%20I%20see%20it%2C%26nbsp%3BNational%20charter%20types%20will%20be%20probably%20deprecated%20sometime%20in%20the%20future%20(not%20in%20a%20year%20or%20two...%20but%20it%20will%20happen...%20it%20must%20happen)%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E(2)%26nbsp%3Bcompatibility%20to%20external%20-%20Most%20operating%20system%20like%20Linux%20and%20Unix%20uses%20UTF-8%20as%20their%20default%20encoding.%20Most%20(if%20not%20all%20except%20some%20poor%20code)%20applications%20uses%20UTF-8%20as%20their%20default%20encoding.%20Have%20you%20ever%20saw%26nbsp%3B%22gibberish%20text%22%20in%20the%20browser%3F!%3F%20THIS%20IS%20DIRECTLY%20RELATED%20TO%20ENCODING%20ISSUES!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EIn%20short...%20you%20need%20to%20hear%20the%20full%20lecture%20%3A)%3C%2Fimg%3E%3C%2FSTRONG%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-771640%22%20slang%3D%22en-US%22%3ERe%3A%20Introducing%20UTF-8%20support%20for%20Azure%20SQL%20Database%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-771640%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F9067%22%20target%3D%22_blank%22%3E%40R%20A%3C%2FA%3E%26nbsp%3BThank%20you%20for%20the%20very%20detailed%20information.%20I%20work%20for%20a%20global%20company%20with%20almost%20all%20internally%20developed%20applications%20using%20.Net%20or%20.Net%20core%20on%20Windows%20with%20Azure%20SQL%20Databases%20(compatibility%20levels%20range%20from%20120%20-%20140).%20Some%20databases%20are%20accessed%20by%20users%20within%20one%20country%2C%20some%20by%20users%20within%20one%20region%2C%20and%20some%20by%20users%20worldwide.%20Most%20strings%20are%20stored%20as%20UNICODE%20(NVARCHAR).%20UTF8%20(or%20possibly%20UTF16%20for%20databases%20used%20primarily%20by%20users%20of%20East%20Asian%20languages)%20seems%20like%20it%20could%20reduce%20storage%20sizes%20for%20such%20strings%2C%20but%20we%20would%20need%20to%20change%20our%20application%20and%20TSQL%20code%20accordingly%2C%20and%20change%20the%20collation%20for%20our%20existing%20databases.%20All%20this%20seems%20like%20a%20massive%20undertaking%2C%20although%20I%20can%20see%20the%20advantages%20for%20new%20applications.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20mention%20in%20one%20of%20your%20slides%20that%20there%20are%20performance%20issues%20with%20UTF8%20but%20don't%20explain%20what%20they%20are.%20Can%20you%20point%20me%20to%20an%20article%20that%20describes%20these%20issues%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-771912%22%20slang%3D%22en-US%22%3ERe%3A%20Introducing%20UTF-8%20support%20for%20Azure%20SQL%20Database%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-771912%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F380947%22%20target%3D%22_blank%22%3E%40m60freeman%3C%2FA%3Eyou%20can%20read%20about%20perf%20differences%20between%20en%3CSPAN%20style%3D%22display%3A%20inline%20!important%3B%20float%3A%20none%3B%20background-color%3A%20%23ffffff%3B%20color%3A%20%23333333%3B%20cursor%3A%20text%3B%20font-family%3A%20inherit%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20line-height%3A%201.7142%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3Ecoding%20types%20in%20this%20blog%3A%26nbsp%3B%3C%2FSPAN%3E%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%20box-sizing%3A%20border-box%3B%20color%3A%20%23333333%3B%20font-family%3A%20%26amp%3Bquot%3B%20segoeui%26amp%3Bquot%3B%2C%26amp%3Bquot%3Blato%26amp%3Bquot%3B%2C%26amp%3Bquot%3Bhelvetica%20neue%26amp%3Bquot%3B%2Chelvetica%2Carial%2Csans-serif%3B%20font-size%3A%2016px%3B%20font-style%3A%20normal%3B%20font-variant%3A%20normal%3B%20font-weight%3A%20300%3B%20letter-spacing%3A%20normal%3B%20orphans%3A%202%3B%20text-align%3A%20left%3B%20text-decoration%3A%20none%3B%20text-indent%3A%200px%3B%20text-transform%3A%20none%3B%20-webkit-text-stroke-width%3A%200px%3B%20white-space%3A%20normal%3B%20word-spacing%3A%200px%3B%22%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FSQL-Server%2FIntroducing-UTF-8-support-for-SQL-Server%2Fba-p%2F734928%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FSQL-Server%2FIntroducing-UTF-8-support-for-SQL-Server%2Fba-p%2F734928%3C%2FA%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CHR%20%2F%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-771923%22%20slang%3D%22en-US%22%3ERe%3A%20Introducing%20UTF-8%20support%20for%20Azure%20SQL%20Database%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-771923%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F194232%22%20target%3D%22_blank%22%3E%40Pedro%20Lopes%3C%2FA%3E%26nbsp%3BI%20guess%20there's%20no%20such%20thing%20as%20a%20free%20lunch.%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-772618%22%20slang%3D%22en-US%22%3ERe%3A%20Introducing%20UTF-8%20support%20for%20Azure%20SQL%20Database%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-772618%22%20slang%3D%22en-US%22%3E%3CBLOCKQUOTE%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F9067%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3E%40R%20A%3C%2FA%3E%3CSPAN%3E%26nbsp%3BThank%20you%20for%20the%20very%20detailed%20information.%3C%2FSPAN%3E%3C%2FBLOCKQUOTE%3E%0A%3CP%3EYou%20are%20most%20welcome%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F380947%22%20target%3D%22_blank%22%3E%40m60freeman%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3EActually%2C%20It%20was%20just%20the%20%22tip%20of%20the%20iceberg%22%20and%20there%20is%20a%20lot%20more%20information%3Agrinning_face%3A%3C%2Fimg%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%0A%3CP%3E%3CSPAN%3ESome%20databases%20are%20accessed%20by%20users%20within%20one%20country%2C%20some%20by%20users%20within%20one%20region%2C%20and%20some%20by%20users%20worldwide.%3C%2FSPAN%3E%3C%2FP%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CP%3ELocation%20of%20the%20clients%20is%20an%20important%20parameter.%20It%20is%20not%20necessarily%20related%20to%20multiple%20languages%20or%20to%20encoding%20but%20it%20has%20it's%20own%20challenge.%3C%2FP%3E%0A%3CP%3EI%20have%20multiple%20lectures%2Fposts%20related%20to%20multi-languages%20databases%20and%20multi-locations%20databases.%20For%20example%20I%20recommend%20the%20lecture%20about%20%22%3CU%3ESQL%20Server%20Non-deterministic%20Elements%3C%2FU%3E%22%2C%20if%20your%20clients%20are%20worldwide.%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgallery.technet.microsoft.com%2FSQL-Server-Non-deterministi-f04efe29%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgallery.technet.microsoft.com%2FSQL-Server-Non-deterministi-f04efe29%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%0A%3CP%3E%3CSPAN%3EUTF8%20(or%20possibly%20UTF16%20for%20databases%20used%20primarily%20by%20users%20of%20East%20Asian%20languages)%3C%2FSPAN%3E%3C%2FP%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CP%3E%3CSTRONG%3ENo%20accurate%3C%2FSTRONG%3E.%20%3CU%3EUTF-8%20is%20used%20in%20all%20countries%20including%20English%20speaking%20languages%3C%2FU%3Elike%20US.%3C%2FP%3E%0A%3CP%3EFor%20example%2C%3C%2FP%3E%0A%3CP%3E(1)%20UTF-8%20is%20the%20official%20standard%20encoding%20for%20web%20application%20for%20example%20according%20to%20the%20w3c%20organisation%20(World%20Wide%20Web%20Consortium).%3C%2FP%3E%0A%3CP%3E(2)%20Moreover...%20Do%20you%20like%20emojis%20%3F!%3F%3C%2FP%3E%0A%3CP%3EDo%20you%20think%20that%20people%20in%20US%20not%20allowed%20to%20use%26nbsp%3Bemojis%2C%20since%20they%20speak%20English%20and%20they%20must%20use%20only%20ASCII%20characters%3F%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EEmojis%20are%20nothing%20but%20simple%20characters%20in%20the%20range%20of%26nbsp%3B65536-1114111%3Aface_with_rolling_eyes%3A%3C%2Fimg%3E.%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EIf%20you%20download%20my%20lecture's%20materials%2C%20then%20you%20can%20find%20scripts%20and%20information%20regarding%20using%26nbsp%3Bemojis.%20In%20the%20section%20where%20I%20speak%20about%26nbsp%3BSupplementary%20Characters.%20I%20use%20emojis%20as%20a%20sample%20of%26nbsp%3BSupplementary%20Characters.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBy%20the%20way%2C%20when%20I%20have%20a%20full%20day%20to%20speak%2Fteach%20about%20the%20topic%2C%20then%20I%20might%20use%20the%20title%20%22%3CSTRONG%3EWriting%20from%2010000%20BC%20to%20SQL%20Server%202019%20and%20beyond%3C%2FSTRONG%3E%22.%20You%20might%20notice%20in%20the%20presentation%20file%20on%20slide%20number%207%2C%20I%20started%20with%20%3CU%3Ethe%20history%20of%20writing%3C%2FU%3Eand%20I%20present%20the%20fact%20that%20it%20all%20started%20with%20%22%3CSTRONG%3EPictograph%3C%2FSTRONG%3E%22%2C%20which%20are%20small%20images%20which%20describe%20what%20the%20person%20see.%20I%20always%20joke%20about%20the%20fact%20that%20history%26nbsp%3Balways%20repeat%20itself%20and%20people%20always%20move%20forward%20until%20they%20find%20themselves%20where%20they%20started...%20The%20definition%20of%26nbsp%3Bemojis%20is%20exactly%20the%20same%20as%20the%26nbsp%3BPictograph%2C%20and%20today%3CU%3Eour%20children%20simply%20went%20back%205000%20years%3C%2FU%3Eto%20the%20abilities%20of%20the%20first%20people%20that%20started%20to%20write.%20Instead%20of%20using%20text%20children%20can%20communicate%20for%20hours%20with%20their%20phone%20purely%20using%26nbsp%3BPictographs%26nbsp%3B(emojis)%20without%20one%20letter%20%3Aeyes%3A%3C%2Fimg%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%0A%3CP%3Eseems%20like%20it%20could%20reduce%20storage%20sizes%20for%20such%20strings%3C%2FP%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CP%3EYou%20focus%20on%20the%20size%2C%20while%20I%20am%20trying%20to%20explain%20that%26nbsp%3Bthe%20size%20of%20the%20stored%20data%20is%20only%20one%20of%20the%20parameters%2C%20and%20not%20necessarily%20the%20most%20important%20one!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%0A%3CP%3Ebut%20we%20would%20need%20to%20change%20our%20application%20and%20TSQL%20code%20accordingly%2C%20and%20change%20the%20collation%20for%20our%20existing%20databases.%20All%20this%20seems%20like%20a%20massive%20undertaking%3C%2FP%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CP%3EYes...%20Moving%20to%20use%20UTF-8%20does%20require%20some%20work%2C%20but%20mostly%20QC%2FQA%20and%20not%20real%20changes%20in%20the%20application%20side%2C%20assuming%20the%20application%20was%20developed%20in%20the%20right%20way%20and%20your%20architecture%20was%20smart%20from%20the%20start.%20In%20this%20case%2C%20this%20procedure%20should%20be%20(almost)%20only%20in%20the%20database%20side.%3C%2FP%3E%0A%3CP%3EMoreover%2C%20you%20should%20remember%20that%20this%20is%20new%20feature%20in%20SQL%20Server%20but%20it%20exists%20for%20many%20years%20in%20other%20databases.%3C%2FP%3E%0A%3CP%3EThe%20idea%20of%20using%20the%20same%20type%20of%20data%20(VARCHAR%20in%20the%20case%20of%20SQ%20Server)%20for%20UNICODE%20exists%20in%20other%20databases%20and%20this%20was%20the%20right%20way%20to%20go%20from%20the%20start%20(IMO).%26nbsp%3B%3CFONT%20color%3D%22%230000FF%22%3EIn%20fact%2C%20Microsoft%20should%20support%20UTF-16%20and%20other%20UNICODE%20encoding%20in%20the%20same%20way%20that%20finally%20support%20UTF-8%20is%20in%20SQL%20Server%202019%20in%20my%20opinion%3C%2FFONT%3E-%20using%20simple%20text%20type%20VARCHAR%2C%20as%20other%20databases%20do.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20had%20a%20good%20architect%20when%20you%20designed%20you%20system%2C%20then%20there%20is%20a%20good%20chance%20that%20your%20system%20was%20designed%20to%20fit%20the%20%22relational%20model%22%20and%20not%20for%20SQL%20Server%20specifically!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%0A%3CP%3E%3CSPAN%3EYou%20mention%20in%20one%20of%20your%20slides%20that%20there%20are%20performance%20issues%20with%20UTF8%20but%20don't%20explain%20what%20they%20are.%3C%2FSPAN%3E%3C%2FP%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CP%3EI%20did%20explain%20and%20even%20mentioned%20it%20again%20at%20the%20end%3A)%3C%2Fimg%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20forget%20that%20you%20only%20watch%20the%20presentation%20file%20and%20not%20hear%20my%20lecture.%20%3CSTRONG%3EThis%20is%20not%20a%20tutorial%20but%20only%20something%20which%20come%20in%20the%20background%20of%20the%20speaker.%3C%2FSTRONG%3E%20A%20presentation%20does%20not%20have%20a%20lot%20of%20meaning%20by%20itself.%20It's%20only%20a%20tool%20which%20come%20in%20the%20background%20of%20the%20speaker's%20lecture.%20If%20I%20had%20a%20recording%20of%20this%20lecture%20in%20English%20then%20I%20could%20add%20the%20link%2C%20but%20the%20only%20time%20I%20was%20recorded%20during%20this%20lecture%20was%20in%20Hebrew%20during%20my%20lecture%20for%20the%20%3CA%20href%3D%22https%3A%2F%2Fglobalhebrew.pass.org%2Fen-us%2Fmeetingdetails.aspx%3FEventID%3D13532%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EPASS%20Hebrew%20Virtual%20group%3C%2FA%3E.%20You%20can%20watch%20the%20Hebrew%20lecture%20if%20you%20want%20here%3A%26nbsp%3B%3CA%20href%3D%22http%3A%2F%2Fyoutu.be%2FAe2ghRyd6ZM%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fyoutu.be%2FAe2ghRyd6ZM%3C%2FA%3E.%20You%20can%3CA%20href%3D%22https%3A%2F%2Fyoutu.be%2FAe2ghRyd6ZM%3Ft%3D285%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ejump%20directly%20to%20the%20point%20that%20I%20start%20to%20speak%3C%2FA%3E(about%204%3A50%20minutes%20after%20the%20start%20of%20the%20meeting).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EIn%20short%3A%3C%2FSTRONG%3EWe%20did%20a%20lot%20of%20tests%20and%20we%20found%20that%20there%20are%20cases%20that%20we%20have%20latency%20when%20we%20use%20UTF-8.%20For%20example%20seems%20that%20some%20of%20the%20%3CU%3Estring%20functions%3C%2FU%3Econvert%20the%20data%20implicitly%20to%20the%20old%20data%20type%20and%20we%20clearly%20noticed%20a%20latency%20(I%20am%20talking%20about%20big%20databases%20with%20multiple%20TB%20of%20data%20and%20using%20big%20tables)%20-%20I%20am%20not%20sure%20that%20in%20your%20case%20you%20will%20be%20able%20to%20feel%20this.%20There%20are%20several%20scenario%20where%20you%20might%20get%20some%20latency%20when%20you%20use%20%3CU%3EUTF-8%20with%20national%20character%20types%3C%2FU%3Etogether.%20There%20are%20the%26nbsp%3Bperformance%20issues%20which%20are%20%3CU%3Erelated%20to%20the%20size%3C%2FU%3E(which%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F194232%22%20target%3D%22_blank%22%3E%40Pedro%20Lopes%3C%2FA%3E%26nbsp%3Bmentioned).%20And%20more...%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBy%20the%20way%2C%20Speaking%20about%20performance%20I%20mentioned%20here%20only%20two%20advantages%20points%20related%20to%20performance%20%22memory%20and%20IO%22%2C%20but%20there%20is%20many%20more%20to%20discuss.%20Here%20is%20another%20example%20out%20of%20many%20more%2C%20which%20I%20mentioned%20in%20the%20lecture%3A%20If%20you%20have%20Non-English%20text%20length%204001%20characters%20then%20you%20use%20NVARCHAR(%3CSTRONG%3E%3CFONT%20color%3D%22%23FF0000%22%3EMAX%3C%2FFONT%3E%3C%2FSTRONG%3E)%20since%20the%20max%20length%20of%20NVARCHAR%20is%204000.%20Using%20MAX%20can%20lead%20to%20VERY%20poor%20performance%20since%20the%20data%20might%20be%20stored%20outside%20the%20row.%20Using%20UTF-8%20we%20can%20use%20VARCHAR%20data%20type%20which%20can%20be%20in%20the%20length%20of%208000%2C%20which%20mean%20we%20can%20use%20VARCHAR(%3CSTRONG%3E%3CFONT%20color%3D%22%23008000%22%3E4001%3C%2FFONT%3E%3C%2FSTRONG%3E)%20which%20will%20store%20the%20data%20in-row.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EI%20hope%20this%20was%20useful%3Agrinning_face%3A%3C%2Fimg%3E%3C%2FSTRONG%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Microsoft

UTF-8 support is now in preview for Azure SQL Database, allowing more options to companies extending their businesses to a global scale, where the requirement of providing global multilingual database applications and services is critical to meet customer demands, and specific market regulations. 

 

If the above requirements resonate with you and your business, then you need a database that supports the full Unicode character set. While this was already possible by choosing a collation that allowed "supplementary characters" and using the NCHAR or NVARCHAR data types, only UTF-16 was supported until now. Azure SQL Database and SQL Server 2019 introduce support for UTF-8 as well, under the CHAR and VARCHAR data types. Choosing whether to use UTF-16 or UTF-8 to support your requirements is the next step, and this blog together with the documentation here should provide more clarity on the topic. So please read on!

 

How is it implemented?

To limit the amount of changes required for the above scenarios, UTF-8 is enabled in existing the data types CHAR and VARCHAR. String data is automatically encoded to UTF-8 when creating or changing an object’s collation to a collation with the “_UTF8” suffix, for example from LATIN1_GENERAL_100_CI_AS_SC to LATIN1_GENERAL_100_CI_AS_SC_UTF8. Refer to Set or Change the Database Collation and Set or Change the Column Collation for more details on how to perform those changes. Note that NCHAR and NVARCHAR remains unchanged and allows UCS-2/UTF-16 encoding.

 

You can see all available UTF-8 collations by executing the following command in your SQL Database:

 

SELECT Name, Description FROM fn_helpcollations()
WHERE Name LIKE '%UTF8';

Functional comparison between UTF-8 and UTF-16

UTF-8 and UTF-16 both handle the same Unicode characters, and both are variable length encodings that require up to 32 bits per character. However, there are important differences that drive the choice of whether to use UTF-8 or UTF-16 in your multilingual database or column:

 

  • UTF-8 encodes the common ASCII characters including English and numbers using 8-bits. ASCII characters (0-127) use 1 byte, code points 128 to 2047 use 2 bytes, and code points 2048 to 65535 use 3 bytes. The code points 65536 to 1114111 use  4 bytes, and represent the character range for Supplementary Characters.
  • But UTF-16 uses at least 16-bits for every character in code points 0 to 65535 (available in UCS-2 and UTF-16 alike), and code points 65536 to 1114111 use the same 4 bytes as UTF-8. 

The table below outlines these storage boundaries:

 

Code Range (hexadecimal)

Code Range (decimal)

Storage bytes with UTF-8

Storage bytes with UTF-16

000000 – 00007F (ASCII)

0 - 127

1

2

000080 – 00009F
0000A0 – 0003FF
000400 – 0007FF

128 – 159
160 – 1,023
1,024 – 2,047

2

2

000800 – 003FFF
004000 – 00FFFF

2,048 - 16,383
16,384 – 65,535

3

2

010000 – 03FFFF
040000 – 10FFFF

65,536 – 262,143
262,144 – 1,114,111

4

4

 

Considerations for choosing UTF-8 or UTF-16

If your dataset uses primarily ASCII characters (which represent majority of Latin alphabets), significant storage savings may be achieved as compared to UTF-16 data types.

For example, changing an existing column data type from NCHAR(10) to CHAR(10) using an UTF-8 enabled collation, translates into nearly 50% reduction in storage requirements. This is because NCHAR(10) requires 22 bytes for storage, whereas CHAR(10) requires 12 bytes for the same Unicode string.

 

What if your dataset is not predominately ASCII? Above the ASCII range, almost all Latin alphabets, but also Greek, Cyrillic, Coptic, Armenian, Hebrew, Arabic, Syriac, Tāna and N’Ko will use 2 bytes per character in both UTF-8 and UTF-16 (128 to 2047). 

 

But Chinese, Japanese, or Korean characters are represented starting in the range 2048 to 65535, and use 3 bytes in UTF-8, but only 2 bytes in UTF-16. If your dataset is mostly in this character range then using UTF-16 is preferred.  

 

In the Supplementary character range (65536 to 1114111) there is no measurable difference between UTF-8 and UTF-16 encoding.

 

To read more about Unicode support in SQL Database, including details on UTF-8 support, see here.

 

How to convert to UTF-8?

Two methods to convert data are described next. 

1) Convert column data. Imagine you have a current table that is encoded in UCS-2/UTF-16 (depends on whether a supplementary character enabled collation is used) or non-Unicode, like the following examples:

 

CREATE TABLE dbo.MyTable (MyString NVARCHAR(50) COLLATE Latin1_General_100_CI_AI_SC);
CREATE TABLE dbo.MyTable (MyString VARCHAR(50) COLLATE Latin1_General_100_CI_AI);

To convert it in-place, run an alter statement, like the following example:

 

ALTER TABLE dbo.MyTable
ALTER COLUMN MyString VARCHAR(50) COLLATE Latin1_General_100_CI_AI_SC_UTF8

It's very easy to implement, however this is a possibly blocking operation which may pose an issue for large tables and busy applications.

 

2) Copy and Replace. This method involves copying data to a new table where the target column(s) are already in UTF-8, and then replace the old table. The following T-SQL example illustrates this using the second example table above:

 

CREATE TABLE dbo.MyTable2 (VARCHAR(50) COLLATE Latin1_General_100_CI_AI_SC_UTF8);
INSERT INTO dbo.MyTable2
SELECT * FROM dbo.MyTable;
DROP TABLE dbo.MyTable;
EXEC sp_rename 'dbo.MyTable2', 'dbo.MyTable’;

This method is much faster, but handling complex schemas with many dependencies (FKs, PKs, Triggers, DFs) and tail of the table synch requires much more preparation.

 

In conclusion, keep the topics discussed here in mind when choosing what encoding to use in your database or columns. Especially in terms of what is the predominant language/character set that's expected to store in a specific table column.

 

Pedro Lopes ( @SQLPedro ) – Senior Program Manager

9 Comments
Regular Visitor

Pedro, this is very helpful in terms of picking UTF-8 vs. UTF-16, but doesn't mention why I might want UTF at all when all my applications that use NVARCHAR work fine using the SQL_Latin1_General_CP1_CI_AS collation, and I'm interested in learning about that. Thanks!

Microsoft

If you are working with NVARCHAR in that collation, then you're using UCS-2 encoding that can represent the first 65535 Unicode characters. Like I started by saying, if you have a requirement of providing global multilingual database applications and services, then you likely need full Unicode support. Same to meet some specific market/industry regulations.

After you set that you do have a requirement to use Unicode, then choosing whether to use UTF-8 or UTF-16 falls into the several considerations explained in this blog, and also in the documentation at https://docs.microsoft.com/en-us/sql/relational-databases/collations/collation-and-unicode-support. Hope this helps.

R A
MVP

Awesome news!

Thanks for sharing Pedro=)

R A
MVP

@m60freeman , There are plenty of reasons why people should (and will) use UTF-8. The size of the stored data is only one of the parameters, and not necessarily the most important!

 

You can download the session's materials from my lecture at sqlsaturday here:

https://gallery.technet.microsoft.com/UTF-8-in-SQL-Server-2019-8d97cca2

 

Go over the presentation file: You can notice that I split the discussion into three levels (1) developers, (2) DBA, (3) Internals

 

From the DBA point of view we discuss the size and performance, but from the developers point of view there is a huge advantage related to "compatibility" which can be much more important than "size" in some cases.

 

I cannot give 75 minutes lecture in one message in the forum but in VERY VERY VERY short (slides 21+25 in the presentation file summarize all in two tables):

 

> Size: as Pedro explained in some ranges of code points the UTF-8 is smaller then UTF-16, but even if you use non-English languages, then this might give you extreme advantage.

For example think about Hebrew forum (or Hebrew message in this forum), and let's assume I simply write my name in the message(this is my real name in Hebrew):

רונן אריאלי.

but... Hebrew is written from RTL (in the above text the dot is not in the right place! In RTL language the Dot should be on the left side), and I need to move the text to the right side of the page as well. In addition, I like myself so I make my name in bold, and I am so happy that this feature finally supported in Azure so I add some coolers to celebrate. The result will look like bellow text:

רונן אריאלי.

The end-user only sees Hebrew letters. Therefore, he might say that UTF-8 will not give him smaller size since Hebrew is the range of 128-2047 and in this rage UTF-8 has the same size as UTF-16. Moreover, we can do the same example with Chinese, Japanese or Korean - in this case the poor clients might say that soince the text in Chinese, Japanese or Korean then it is in the range of 2048 – 65535 which mean the size will be 1.5 bigger in UTF-8! Are these arguments correct?!?

The data in the database does not includes plain text, but all the HTML/CSS code behind the scene as well!

The fact is that for this simple short name the server actually stores the following code!

 

<p style="direction: rtl;">
    <strong>
        <span style="background-color: #ffff99; color: #339966;">ר</span>
        <span style="background-color: #00ff00; color: #ff0000;">ו</span>
        <span style="background-color: #0000ff; color: #ffffff;">נ</span>
        <span style="background-color: #808080; color: #ff99cc;">ן</span> 
        <span style="background-color: #000000; color: #ccffcc;">א</span>
        <span style="background-color: #ff99cc; color: #000080;">ר</span>
        <span style="background-color: #808080; color: #ff00ff;">י</span>
        <span style="background-color: #ffffff; color: #993300;">א</span>
        <span style="background-color: #003300; color: #ffcc99;">ל</span>
        <span style="background-color: #ccffcc; color: #993300;">י</span>
        <span style="background-color: #333300; color: #ffffff;">.</span>
    </strong>
</p>

This code includes 898 characters, and only 10 of these are in Hebrew, while the rest are in ASCII range!

 

This means that using NVARCHAR we use (898*2) = 1796 bytes, but using UTF-8 we will use only (888*1)+(10*3) = 918 bytes!

Therefore, even for Non-English languages we might want to use UTF-8

 

> Performance: Size directly related to memory and IO

 

> compatibility: There are two aspects of compatibility! (1) compatibility inside the server between different values. (2) compatibility to external applications, Operating systems and so on

 

(1) compatibility inside the server: NVARCHAR data type is not fully compatible with VARCHAR and using combination of text in NVARCHAR with text in VARCHAR you might get a very strange and unexpected result (at least unexpected by most users). The entire idea that we have to use two different types of data (National charter types like VARCHAR, NCHAR, XML and Non-National charter types like CHAR, VARCHAR) is a base for multiple issues and performance related to converting the types behind the scene.

As I see it, National charter types will be probably deprecated sometime in the future (not in a year or two... but it will happen... it must happen)

(2) compatibility to external - Most operating system like Linux and Unix uses UTF-8 as their default encoding. Most (if not all except some poor code) applications uses UTF-8 as their default encoding. Have you ever saw "gibberish text" in the browser?!? THIS IS DIRECTLY RELATED TO ENCODING ISSUES!

 

In short... you need to hear the full lecture :)

R A
MVP

I updated the message. I mistakenly added link to a different lecture. Now the link to the download is correct :)

Regular Visitor

@R A Thank you for the very detailed information. I work for a global company with almost all internally developed applications using .Net or .Net core on Windows with Azure SQL Databases (compatibility levels range from 120 - 140). Some databases are accessed by users within one country, some by users within one region, and some by users worldwide. Most strings are stored as UNICODE (NVARCHAR). UTF8 (or possibly UTF16 for databases used primarily by users of East Asian languages) seems like it could reduce storage sizes for such strings, but we would need to change our application and TSQL code accordingly, and change the collation for our existing databases. All this seems like a massive undertaking, although I can see the advantages for new applications.

 

You mention in one of your slides that there are performance issues with UTF8 but don't explain what they are. Can you point me to an article that describes these issues?

Microsoft

@m60freeman you can read about perf differences between encoding types in this blog: https://techcommunity.microsoft.com/t5/SQL-Server/Introducing-UTF-8-support-for-SQL-Server/ba-p/7349...


 

Regular Visitor

@Pedro Lopes I guess there's no such thing as a free lunch. :)

R A
MVP
@R A Thank you for the very detailed information.

You are most welcome @m60freeman.

Actually, It was just the "tip of the iceberg" and there is a lot more information:grinning_face:

 

Some databases are accessed by users within one country, some by users within one region, and some by users worldwide.

Location of the clients is an important parameter. It is not necessarily related to multiple languages or to encoding but it has it's own challenge.

I have multiple lectures/posts related to multi-languages databases and multi-locations databases. For example I recommend the lecture about "SQL Server Non-deterministic Elements", if your clients are worldwide.

https://gallery.technet.microsoft.com/SQL-Server-Non-deterministi-f04efe29

 

UTF8 (or possibly UTF16 for databases used primarily by users of East Asian languages)

No accurate. UTF-8 is used in all countries including English speaking languages like US.

For example,

(1) UTF-8 is the official standard encoding for web application for example according to the w3c organisation (World Wide Web Consortium).

(2) Moreover... Do you like emojis ?!?

Do you think that people in US not allowed to use emojis, since they speak English and they must use only ASCII characters? 

Emojis are nothing but simple characters in the range of 65536-1114111:face_with_rolling_eyes:.

If you download my lecture's materials, then you can find scripts and information regarding using emojis. In the section where I speak about Supplementary Characters. I use emojis as a sample of Supplementary Characters.

 

By the way, when I have a full day to speak/teach about the topic, then I might use the title "Writing from 10000 BC to SQL Server 2019 and beyond". You might notice in the presentation file on slide number 7, I started with the history of writing and I present the fact that it all started with "Pictograph", which are small images which describe what the person see. I always joke about the fact that history always repeat itself and people always move forward until they find themselves where they started... The definition of emojis is exactly the same as the Pictograph, and today our children simply went back 5000 years to the abilities of the first people that started to write. Instead of using text children can communicate for hours with their phone purely using Pictographs (emojis) without one letter :eyes:

 

seems like it could reduce storage sizes for such strings

You focus on the size, while I am trying to explain that the size of the stored data is only one of the parameters, and not necessarily the most important one!

 

but we would need to change our application and TSQL code accordingly, and change the collation for our existing databases. All this seems like a massive undertaking

Yes... Moving to use UTF-8 does require some work, but mostly QC/QA and not real changes in the application side, assuming the application was developed in the right way and your architecture was smart from the start. In this case, this procedure should be (almost) only in the database side.

Moreover, you should remember that this is new feature in SQL Server but it exists for many years in other databases.

The idea of using the same type of data (VARCHAR in the case of SQ Server) for UNICODE exists in other databases and this was the right way to go from the start (IMO). In fact, Microsoft should support UTF-16 and other UNICODE encoding in the same way that finally support UTF-8 is in SQL Server 2019 in my opinion - using simple text type VARCHAR, as other databases do.

 

If you had a good architect when you designed you system, then there is a good chance that your system was designed to fit the "relational model" and not for SQL Server specifically!

 

You mention in one of your slides that there are performance issues with UTF8 but don't explain what they are.

I did explain and even mentioned it again at the end:)

 

You forget that you only watch the presentation file and not hear my lecture. This is not a tutorial but only something which come in the background of the speaker. A presentation does not have a lot of meaning by itself. It's only a tool which come in the background of the speaker's lecture. If I had a recording of this lecture in English then I could add the link, but the only time I was recorded during this lecture was in Hebrew during my lecture for the PASS Hebrew Virtual group. You can watch the Hebrew lecture if you want here: http://youtu.be/Ae2ghRyd6ZM . You can jump directly to the point that I start to speak (about 4:50 minutes after the start of the meeting).

 

In short: We did a lot of tests and we found that there are cases that we have latency when we use UTF-8. For example seems that some of the string functions convert the data implicitly to the old data type and we clearly noticed a latency (I am talking about big databases with multiple TB of data and using big tables) - I am not sure that in your case you will be able to feel this. There are several scenario where you might get some latency when you use UTF-8 with national character types together. There are the performance issues which are related to the size (which @Pedro Lopes mentioned). And more...

 

By the way, Speaking about performance I mentioned here only two advantages points related to performance "memory and IO", but there is many more to discuss. Here is another example out of many more, which I mentioned in the lecture: If you have Non-English text length 4001 characters then you use NVARCHAR(MAX) since the max length of NVARCHAR is 4000. Using MAX can lead to VERY poor performance since the data might be stored outside the row. Using UTF-8 we can use VARCHAR data type which can be in the length of 8000, which mean we can use VARCHAR(4001) which will store the data in-row.

 

I hope this was useful:grinning_face: