Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Conversion failed when converting varchar to data type int

$
0
0

Sorry to ask such a dumb question, but why can I not convert a varchar to int?

Select [Index Name],  count([adj count]) as 'total', cast([adj count] as int) as 'adj count'--, count([adj count]) as 'total'
FROM [Test_DB].[dbo].[SPBMI_Count]
Where [Index Name] in ('S&P Global Ex-U.S. LargeMidCap (US Dollar)','S&P Emerging SmallCap (US Dollar)',
'S&P Global BMI (US Dollar)', 'S&P Emerging LargeMidCap (US Dollar)',  
'S&P Global Ex-U.S. SmallCap (US Dollar)')
group by [Index Name],[adj count]

The problem is here.

cast([adj count] as int) as 'adj count'

The datatype is varchar(10)

I tried both cast & Convert; neither works.


Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>