Differences :
1 Character Data Type
Varchar - Non-Unicode Data
NVarchar - Unicode Data
2 Character Size
Varchar - 1 byte
NVarchar - 2 bytes
3 Maximum Length
Varchar - 8,000 bytes
NVarchar - 4,000 bytes
4 Storage Size
Varchar - Actual Length (in bytes)
NVarchar - 2 times Actual Length (in bytes)
5 Example
DECLARE @FirstName AS VARCHAR(50) = ‘Techie’
SELECT @FirstName AS FirstName,
DATALENGTH(@FirstName) AS
Length
Result:
FirstName Length
Techie 6
DECLARE @FirstName AS NVARCHAR(50)= ‘Techie’ SELECT @FirstName AS FirstName, DATALENGTH(@FirstName) AS Length
Result:
FirstName Length Techie 12
* The abbreviation for Varchar is Variable Length character String.
* The abbreviation of NVarchar is uNicode Variable Length character String.
1 Character Data Type
Varchar - Non-Unicode Data
NVarchar - Unicode Data
2 Character Size
Varchar - 1 byte
NVarchar - 2 bytes
3 Maximum Length
Varchar - 8,000 bytes
NVarchar - 4,000 bytes
4 Storage Size
Varchar - Actual Length (in bytes)
NVarchar - 2 times Actual Length (in bytes)
5 Example
DECLARE @FirstName AS VARCHAR(50) = ‘Techie’
SELECT @FirstName AS FirstName,
DATALENGTH(@FirstName) AS
Length
Result:
FirstName Length
Techie 6
DECLARE @FirstName AS NVARCHAR(50)= ‘Techie’ SELECT @FirstName AS FirstName, DATALENGTH(@FirstName) AS Length
Result:
FirstName Length Techie 12
* The abbreviation for Varchar is Variable Length character String.
* The abbreviation of NVarchar is uNicode Variable Length character String.
No comments:
Post a Comment