Before I change a production table I want to be sure that the data remains intact. So I wrote a simple script to check that values of the fields.
Here is an Example of the data.
OutPut
[tt]
ID Text_Comment_Length VarChar_Comment_Length
----------- ------------------- ----------------------
1 232 116
[/tt]
ID Text_Comment
----------- -----------------------------------------------------------------------------------------------------------------------
1 This is a test of the emergancy brocast service, if this were a real emergancy you would be running for the hills!!!
ID nVarChar_Comment
----------- -----------------------------------------------------------------------------------------------------------------------
1 This is a test of the emergancy brocast service, if this were a real emergancy you would be running for the hills!!!
As you can see the text of both is them same, but the lenght test differs.
WHY??
Thanks
John Fuhrman
Here is an Example of the data.
Code:
Declare @TestTable Table
(
ID Int IDENTITY,
COMMENT nTEXT,
Primary Key (ID)
)
Insert Into @TestTable Values ('This is a test of the emergancy brocast service, if this were a real emergancy you would be running for the hills!!!')
Select
ID,
DATALENGTH(COMMENT) As Text_Comment_Length,
Len(Cast(COMMENT As nVarChar(Max))) As VarChar_Comment_Length
From @TestTable
OutPut
[tt]
ID Text_Comment_Length VarChar_Comment_Length
----------- ------------------- ----------------------
1 232 116
[/tt]
ID Text_Comment
----------- -----------------------------------------------------------------------------------------------------------------------
1 This is a test of the emergancy brocast service, if this were a real emergancy you would be running for the hills!!!
ID nVarChar_Comment
----------- -----------------------------------------------------------------------------------------------------------------------
1 This is a test of the emergancy brocast service, if this were a real emergancy you would be running for the hills!!!
As you can see the text of both is them same, but the lenght test differs.
WHY??
Thanks
John Fuhrman