i am trying to know the data is getting loaded in single byte or double byte data, please find the column data as pasted below:
حمد بخش مبار
select CTD_BENAC_NAME
from NAME_TRAN_DETAILS
where CTD_SEND_INS_REF ='FTSCWOK11074799'
it will gives the arabic data in the result, now i just want to know data is getting loaded in Single byte or double byte in Sqlserver, kindly advice how can i decide?
It depends on the data type of that column. In SQL Server there are two kinds of character data types — regular and Unicode. Regular data types which are
CHARandVARCHAR. Unicode data types likeNCHARandNVARCHAR. For regular characters SQL Server uses one byte of storage for each character, whereas Unicode charactersNVARCHARuses two bytes per character.You can also get the number of bytes used by a string using
DATALEGNTHorLENlike so:As I explained later, If this
inputstringis of typeNVARCHARorN'string'DATALENGTHwill give you the number of bytes. Whereas theLENwill give you the nuber of characters in a sting and that length is not necessarily the number of bytes.Note that, another difference between
LENandDATALENGTHis that theLENexcludes trailing blanks while theDATALENGTHdoesn’t. Also, be careful with theses functions because it would depend in the collation because Varchar = single byte is not always true as pointed out by @MartinSmith comment below.Here is a demo for that, you can try it yourself.
DEMO