CAST or CONVERT: 'ntext' error
developmentalmadness
Posts: 3
I have two copies of a database, one just created from a restore of a backup minutes before.
When I try and run Data Compare, it doesn't seem to matter which options I specify I get some form of the following error:
The following error message was returned from the SQL Server:
[291] CAST or CONVERT: invalid attributes specified for type 'ntext'
CAST or CONVERT: invalid attributes specified for type 'ntext'
CAST or CONVERT: invalid attributes specified for type 'ntext'
The following SQL command caused the error:
SELECT [AutoNumber], convert(nvarchar(1),[Type]) COLLATE Latin1_General_BIN , [NumericKey], [ItemNumber], convert(nvarchar(100),[AlphaKey]) COLLATE Latin1_General_BIN , [EntryDate], [EntryTime], convert(ntext(16),[Notes]) COLLATE Latin1_General_BIN , convert(nvarchar(255),[Event]) COLLATE Latin1_General_BIN , convert(nvarchar(255),[FollowupAction]) COLLATE Latin1_General_BIN , convert(nvarchar(50),[AssignedTo]) COLLATE Latin1_General_BIN , [ScheduledDate], [ScheduledTime], [ActualDate], [ActualTime], [Completed], convert(nvarchar(50),[EnteredBy]) COLLATE Latin1_General_BIN , convert(nvarchar(20),[Priority]) COLLATE Latin1_General_BIN , convert(nvarchar(20),[Status]) COLLATE Latin1_General_BIN , convert(nvarchar(250),[Keywords]) COLLATE Latin1_General_BIN , convert(ntext(16),[EmailOutgoing]) COLLATE Latin1_General_BIN , convert(ntext(16),[EmailIncoming]) COLLATE Latin1_General_BIN , convert(nvarchar(1),[ParentType]) COLLATE Latin1_General_BIN , convert(nvarchar(100),[ParentKey]) COLLATE Latin1_General_BIN , [TimeStamp]
FROM [dbo].[Notes] WITH (NOLOCK) ORDER BY [AutoNumber]
The columns are "text" not "ntext" (same goes for "varchar"/"nvarchar") and I can't seem to find any options to control any of this.
I'm evaluating Data Compare for a client. I've used it in the past and never run into this kind of thing before. Any help would be appreciated.
@VERSION:
Microsoft SQL Server 2008 R2 (SP1) - 10.50.2550.0 (X64)
Jun 11 2012 16:41:53
Copyright (c) Microsoft Corporation
Express Edition with Advanced Services (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)
When I try and run Data Compare, it doesn't seem to matter which options I specify I get some form of the following error:
The following error message was returned from the SQL Server:
[291] CAST or CONVERT: invalid attributes specified for type 'ntext'
CAST or CONVERT: invalid attributes specified for type 'ntext'
CAST or CONVERT: invalid attributes specified for type 'ntext'
The following SQL command caused the error:
SELECT [AutoNumber], convert(nvarchar(1),[Type]) COLLATE Latin1_General_BIN , [NumericKey], [ItemNumber], convert(nvarchar(100),[AlphaKey]) COLLATE Latin1_General_BIN , [EntryDate], [EntryTime], convert(ntext(16),[Notes]) COLLATE Latin1_General_BIN , convert(nvarchar(255),[Event]) COLLATE Latin1_General_BIN , convert(nvarchar(255),[FollowupAction]) COLLATE Latin1_General_BIN , convert(nvarchar(50),[AssignedTo]) COLLATE Latin1_General_BIN , [ScheduledDate], [ScheduledTime], [ActualDate], [ActualTime], [Completed], convert(nvarchar(50),[EnteredBy]) COLLATE Latin1_General_BIN , convert(nvarchar(20),[Priority]) COLLATE Latin1_General_BIN , convert(nvarchar(20),[Status]) COLLATE Latin1_General_BIN , convert(nvarchar(250),[Keywords]) COLLATE Latin1_General_BIN , convert(ntext(16),[EmailOutgoing]) COLLATE Latin1_General_BIN , convert(ntext(16),[EmailIncoming]) COLLATE Latin1_General_BIN , convert(nvarchar(1),[ParentType]) COLLATE Latin1_General_BIN , convert(nvarchar(100),[ParentKey]) COLLATE Latin1_General_BIN , [TimeStamp]
FROM [dbo].[Notes] WITH (NOLOCK) ORDER BY [AutoNumber]
The columns are "text" not "ntext" (same goes for "varchar"/"nvarchar") and I can't seem to find any options to control any of this.
I'm evaluating Data Compare for a client. I've used it in the past and never run into this kind of thing before. Any help would be appreciated.
@VERSION:
Microsoft SQL Server 2008 R2 (SP1) - 10.50.2550.0 (X64)
Jun 11 2012 16:41:53
Copyright (c) Microsoft Corporation
Express Edition with Advanced Services (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)
Comments
If I remove the text column from the comparison, then it works. The problem is that Data Compare is trying to pass a "size" argument to the convert function for text data types.
convert(ntext(16),[EmailIncoming]) COLLATE Latin1_General_BIN
There doesn't seem to be anything I can do about this on my side and I find it hard to believe that this problem even exists. I can duplicate the problem with the following script:
We have logged a support ticket for you and will email you shortly!
Product Support
Redgate Software Ltd.
E-mail: support@red-gate.com
1) Create a database with the default collation set to Latin1_General_100_CI_AI
CREATE DATABASE RedGate1
COLLATE Latin1_General_100_CI_AI
GO
USE RedGate1;
CREATE TABLE MyTest (
[Id] INT PRIMARY KEY IDENTITY(1,1),
[MyValue] TEXT
)
INSERT INTO MyTest (MyValue) VALUES ('some text')
GO
Then create a duplicate database with the same name - the collation on the 2nd database won't matter.
2) OR create a database with the default collation, then create a table whose TEXT column has its collation set to Latin1_General_100_CI_AI
CREATE DATABASE RedGate1
GO
USE RedGate1;
CREATE TABLE MyTest (
[Id] INT PRIMARY KEY IDENTITY(1,1),
[MyValue] TEXT COLLATE Latin1_General_100_CI_AI
)
INSERT INTO MyTest (MyValue) VALUES ('some text')
GO