VARCHAR: The VARCHAR is most widely used into the sql server to store non-unicode variable length type of data or string data.
VARCHAR stores data at 1 byte per character and it can store non-unicode characters or string data.
VARCHAR supports upto 8000 characters.
VARCHAR is a variable length and it takes less memory space.
The use of VARCHAR in sql server is as follows:
DECLARE @NAME VARCHAR(50)
SET @NAME = 'RAMAN SACHDEVA'
SELECT @NAME AS NAME
SELECT DATALENGTH(@NAME) AS NAME_DATALENGTH
After execution of above scripts, the result would be:
NAME: RAMAN SACHDEVA
DATALENGTH: 14
NVARCHAR: The NVARCHAR is most widely used into the sql server to store unicode variable length type of data or string data.
NVARCHAR stores data at 2 byte per character and it can store unicode characters or string data.
NVARCHAR supports upto 4000 characters.
The use of NVARCHAR in sql server is as follows:
DECLARE @NAME1 NVARCHAR(50)
SET @NAME1 = 'PALKA SACHDEVA'
SELECT @NAME1 AS NAME
SELECT DATALENGTH(@NAME1) AS NAME1_DATALENGTH
After execution of above scripts, the result would be:
NAME: PALKA SACHDEVA
DATALENGTH: 28
You can see the below screenshots for further clarification:
No comments:
Post a Comment