Reputation: 2455
How can I transform/convert/cast a column with type [ntext] into a column type [int]? Let's suppose the column name is Client_ID and the table is Client. I am using MS SQL Server 2014.
I tried with:
SELECT
CONVERT (INT, a.CONTRACT_ID)
FROM [dbo].[src_CONTRACT_CONFIGXML] as a
The error message I am getting is: "Explicit conversion from data type ntext to int is not allowed."
Upvotes: 7
Views: 9782
Reputation:
Try this:
SELECT
CONVERT(INT,CONVERT(VARCHAR(20),Client_ID)) AS ClientID
FROM Client
Upvotes: 1
Reputation: 2970
You first convert it to NVARCHAR and then to INT. As follows:
CONVERT(INT, CONVERT(NVARCHAR(100), CONTRACT_ID))
Upvotes: 13