marrowyung
asked on
MS SQL server Varchar and nvarchar, GMT_DATE
hi all,
is it say that nvarchar take up more space than varchar, how much more it takes?
other than GTM_DATE, another other DATE type which is smaller in size and can record GMT value ?
is it say that nvarchar take up more space than varchar, how much more it takes?
other than GTM_DATE, another other DATE type which is smaller in size and can record GMT value ?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Pawan Kumar Khowal,
"
Is GTM_DATE DATETIME
and OtherDate DATE
"
what is that mean ?
Daniel Jones,
" Both function identically but nvarchar takes up twice as much space."
but you agree on that:
NVarchar[(n)] -- Unicode Variable Length character data type. It can store both non-Unicode and Unicode (i.e. Hindi, Chineese, Japanese, Korean ,, etc) characters.
right?
"
Is GTM_DATE DATETIME
and OtherDate DATE
"
what is that mean ?
Daniel Jones,
" Both function identically but nvarchar takes up twice as much space."
but you agree on that:
NVarchar[(n)] -- Unicode Variable Length character data type. It can store both non-Unicode and Unicode (i.e. Hindi, Chineese, Japanese, Korean ,, etc) characters.
right?
2nd question - other than GTM_DATE, another other DATE type which is smaller in size and can record GMT value is not clear ?
I have already given the example for the information I gave.
You can also verify the information from Pinal's blog - http://blog.sqlauthority.com/2015/02/25/sql-server-storing-data-in-hindi-chinese-gujarati-and-tamil-or-any-other-language-in-the-same-table/
Hope that helps !
I have already given the example for the information I gave.
You can also verify the information from Pinal's blog - http://blog.sqlauthority.com/2015/02/25/sql-server-storing-data-in-hindi-chinese-gujarati-and-tamil-or-any-other-language-in-the-same-table/
Hope that helps !
ASKER
I think the new EE question page is not clear, if you look above, I see no link from you .
but that page is only about:
NVarchar[(n)] -- Unicode Variable Length character data type. It can store both non-Unicode and Unicode (i.e. Hindi, Chineese, Japanese, Korean ,, etc) characters.
agree?
but that page is only about:
NVarchar[(n)] -- Unicode Variable Length character data type. It can store both non-Unicode and Unicode (i.e. Hindi, Chineese, Japanese, Korean ,, etc) characters.
agree?
Yes I agree. Did you see the URL below-
http://blog.sqlauthority.com/2015/02/25/sql-server-storing-data-in-hindi-chinese-gujarati-and-tamil-or-any-other-language-in-the-same-table/
http://blog.sqlauthority.com/2015/02/25/sql-server-storing-data-in-hindi-chinese-gujarati-and-tamil-or-any-other-language-in-the-same-table/
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Just to append..
Varchar - Each character will take 1 Byte. If you have 5 characters then it will take 5 characters. i.e. VARCHAR(5)
NVarchar - Each character will take 2 Byte. If you have 5 characters then it will take 10 characters. NVARCHAR(5)
You can verify how much space each takes using below example.
DECLARE @Name AS VARCHAR(50) = 'Pawan'
SELECT @Name Name, DATALENGTH(@Name) Lengthx
GO
Output
--------
Name Lengthx
Pawan 5
DECLARE @Name AS NVARCHAR(50) = N'Pawan'
SELECT @Name Name, DATALENGTH(@Name) Lengthx
GO
Output
--------
Name Lengthx
Pawan 10
Just an update if you need complete difference list between the 2 data types then refer below -
http://sqlhints.com/2011/12/23/difference-between-varchar-and-nvarchar/
Hope it helps!
Varchar - Each character will take 1 Byte. If you have 5 characters then it will take 5 characters. i.e. VARCHAR(5)
NVarchar - Each character will take 2 Byte. If you have 5 characters then it will take 10 characters. NVARCHAR(5)
You can verify how much space each takes using below example.
DECLARE @Name AS VARCHAR(50) = 'Pawan'
SELECT @Name Name, DATALENGTH(@Name) Lengthx
GO
Output
--------
Name Lengthx
Pawan 5
DECLARE @Name AS NVARCHAR(50) = N'Pawan'
SELECT @Name Name, DATALENGTH(@Name) Lengthx
GO
Output
--------
Name Lengthx
Pawan 10
Just an update if you need complete difference list between the 2 data types then refer below -
http://sqlhints.com/2011/12/23/difference-between-varchar-and-nvarchar/
Hope it helps!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I am not sure how can we make a diff between the GMT_DATE and normal DATE .
Can you explain how do you want to differentiate?
ASKER
I just don't understand why we have the DATE type but still need this.
If you store only date without time then you can use it.
Earlier we have DATETIME where we can store Date and time together.
In DATE data type we can only store Date.
Even in case of user defined data types you have to create user defined data type via system defined data types.
Hope it helps!
Earlier we have DATETIME where we can store Date and time together.
In DATE data type we can only store Date.
Even in case of user defined data types you have to create user defined data type via system defined data types.
Hope it helps!
ASKER
i am sorry that I only focus on the GMT_DATE type we have,.
GMT_DATE type is of DATETIME data type. It is a user defined data type - derived from Datetime system data type.
What's your question on that?
What's your question on that?
ASKER
I am not sure why we use GTM_DATE instead of DATE.
GMT_DATE type is of DATETIME data type. It is a user defined data type - derived from Datetime system data type.
User-defined data types are used when multiple tables must store the same type of data in a column and we must ensure that these columns <<from multiple tables>> should have identical same data type, length, and Null functionality.
That is why the developer uses User-defined data types.
User-defined data types are used when multiple tables must store the same type of data in a column and we must ensure that these columns <<from multiple tables>> should have identical same data type, length, and Null functionality.
That is why the developer uses User-defined data types.
that type is what we defined, see attached.Oh man, you're talking about a user defined data type.
I am not sure why we use GTM_DATE instead of DATE.You'll need to ask this question to who created the GTM_DATE. Btw, GTM_DATE is a datetime and not a date data type.
ASKER
"You'll need to ask this question to who created the GTM_DATE. Btw, GTM_DATE is a datetime and not a date data type."
ahhaha, know you will say this, I just want to get some sense here if this is normal,
from SQL SSMS, it said it is a user defined date data type,... so I said that.
yeah, it is a datetime type all allow.
Pawan,
"GMT_DATE type is of DATETIME data type. It is a user defined data type - derived from Datetime system data type."
it if is user defined, we defined it, so no one should know it, so are you team also use this too ?
"User-defined data types are used when multiple tables must store the same type of data in a column and we must ensure that these columns <<from multiple tables>> should have identical same data type, length, and Null functionality.
"
can't sure what exact it means, all table will have a chance to have a columns from data of other tables, right? this should not be the point of creating another type.
but I think it just make developer make up a type they want for their application, right ?
ahhaha, know you will say this, I just want to get some sense here if this is normal,
from SQL SSMS, it said it is a user defined date data type,... so I said that.
yeah, it is a datetime type all allow.
Pawan,
"GMT_DATE type is of DATETIME data type. It is a user defined data type - derived from Datetime system data type."
it if is user defined, we defined it, so no one should know it, so are you team also use this too ?
"User-defined data types are used when multiple tables must store the same type of data in a column and we must ensure that these columns <<from multiple tables>> should have identical same data type, length, and Null functionality.
"
can't sure what exact it means, all table will have a chance to have a columns from data of other tables, right? this should not be the point of creating another type.
but I think it just make developer make up a type they want for their application, right ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
from SQL SSMS, it said it is a user defined date data type,... so I said that.SSMS doesn't lie. I'm not sure if I understand what's your doubt with this. Do you know what a user defined data type is, right?
ASKER
tks all.
ASKER
yeah, that type just means we all reference the same type.
I just want to know it as I don't involve on any of this.
I just want to know it as I don't involve on any of this.
Example:
DECLARE @Name AS NVARCHAR(100)= N'पवन'
SELECT @Name
GO
Varchar[(n)] -- Non-Unicode Variable Length character data type.
Example:
DECLARE @Name AS VARCHAR(100)= 'Pawan'
SELECT @Name
GO
Difference
-------------
Open in new window
Output
-------------
(No column name) (No column name)
पवन ???
Is GTM_DATE DATETIME
and OtherDate DATE
Hope it helps !!