My String.sql

SELECT DATALENGTH(CAST('My String Value' AS NCHAR(20))) AS 'NCHAR' , DATALENGTH(CAST('My String Value' AS NVARCHAR(20))) AS 'NVARCHAR' , DATALENGTH(CAST('My String Value' AS CHAR(20))) AS 'CHAR' , DATALENGTH(CAST('My String Value' AS VARCHAR(20))) AS 'VARCHAR'
The script in Listing uses the DATALENGTH system function to demonstrate the difference in storage size for a 15-character string, cast as each character data type.

1 Response

Examining the Storage Size of Strings

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.