I'm trying to write a T-SQL script to align two copies of a database with the
tablediff
utility exposed by SQL Server but I am facing a problem with all the rows of a text field inside a table.
The problem is that all the strings stored on that text field are null-terminated (there actually is a null character at the end of the string if I export them to a text file) and the INSERT
and UPDATE
queries generated by tablediff
are all failing due to the fact that that null terminator truncates the query.
Is there a way to prevent the generated scripts from failing?
UPDATE
Creation query generated by MSSQL for the table I'm trying to align
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[TABTEST](
[Code] [varchar](50) NOT NULL,
[Source] [text] NULL,
CONSTRAINT [PrK_TABTEST] PRIMARY KEY CLUSTERED
(
[Code] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
Insert query generated by tablediff
(keep in mind that the character you don't see at the end of the Source
after the NOOP
is an ANSI NULL character)
UPDATE [dbo].[TABTEST] SET [Source]=N'NOOP ' WHERE [Code] = N'TestCode'