I have a table with a field of type NTEXT , which stores many types of values, the file size among them. I am trying to run a query in a list of entries and add file sizes, but I ran into this problem.
Since NTEXT cannot be directly / implicitly converted to INT or BIGINT , I first convert it to VARCHAR strong>, then I try to convert it to INT or BIGINT. Everything goes fine until I try to convert the VARCHAR value to INT or BIGINT .
Here are my queries and results:
First I try the following, which shows no problems, and the output is 61069 (the value is still like a text type).
SELECT FileSize
FROM dbo.myTable
WHERE ID = 111
Now I convert / apply it as varchar, and again, no problem. The output is 61069 (now type varchar).
SELECT CONVERT(VARCHAR, FileSize)
FROM dbo.myTable
WHERE ID = 111
Finally, I try to convert the VARCHAR value to BIGINT so that I can perform my SUM () and other calculations, but this time I get a " Error converting varchar data type to bigint. " Message.
SELECT CONVERT(BIGINT, CONVERT(VARCHAR, FileSize))
FROM dbo.myTable
WHERE ID = 111
And if I try to convert it to INT instead, I get " Conversion failed when converting varchar '7/1/2008 3:39:30 AM' to an int data type "
SELECT CONVERT(INT, CONVERT(VARCHAR, FileSize))
FROM dbo.myTable
WHERE ID = 111
I'm completely lost, any ideas on what could be causing this?