♣ Tech & Biz Salon/Tech

SQLServer Function - Get Byte Length ( Like Oracle LENGTHB )

TasteGod 2012. 12. 28. 15:16

Oracle의 LENGTHB 같은게 없나 싶었는데 있네요.

아마도 예전에는 없다가 최근 버젼부터 나오는게 아닐까 생각도 듭니다.


The LEN (length) function returns the number of characters in a string expression, excluding any blanks after the last character (trailing blanks). DATALENGTH, on the other hand, returns the number of bytes used for an expression. In this recipe, I will demonstrate how to measure the number of characters and bytes in a string.






This first example returns the number of characters in the string:

SELECT LEN(N'She sells sea shells by the sea shore.')

This would return 38

This next example returns the number of bytes in the string.

SELECT DATALENGTH(N'She sells sea shells by the sea shore.')

This would return 76


FROM : http://learnsqlserver.in/2/Length-Function.aspx