I have two databases in Azure SQL Server.
I have a table called AUDIT_TAB
which should be absolutely identical in each, both in structure and in contents.
CREATE TABLE [DB].[AUDIT_TAB]
(
...
[THE_TEXT] [varchar](1000) NULL,
[UPDATE_DATE] [datetime2](0) NOT NULL,
[UPDATE_USER_ID] [numeric](6, 0) NOT NULL
) ON [PRIMARY]
The THE_TEXT
column is populated with data which includes carriage returns.
The query
select *
from db.audit_tab
where the_text like '%'+char(10)+'%'
returns the same rows for each database.
The following query which converts the the_text
field into hexadecimal
select convert(varchar(max), convert(varbinary(max), the_text),1)
from db.audit_tab
returns exactly the same for each database.
I have a Java application attached to each database. The same Java application reads one table with the carriage returns, and one table without the carriage returns.
Now, in SSMS itself there is an option to copy CR/LF directly from the tables.
Before I discovered this option, then one instance of my table showed the CR/LF and one instance of my table did not show the CR/LF. There seems to be have been some kind of internal discrepancy between the two databases as to whether to display the CR/LF or not. Now that I have started using this option, both databases seem to work identically in SSMS.
Notwithstanding the fact that in SSMS the problem is solved, the Java applications still read the table differently. One reads it with carriage returns, and one without.
I suspect that the same internal discrepancy between the two databases which caused SSMS to initially display the tables differently, is also causing the Java applications to read the tables differently.
Any ideas?