我已经从csv命名的动物数据中导入了所有数据。我可以用select *(我得到以下结果)查询
但是当我尝试查询以下内容时
select ["Max Weight"]
from dbo.animaldata
where ["Max Weight"] > 5
Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the varchar value 'NA' to data type int.
select ["Sex"]
from animaldata
where ["Sex"] = "male"
Msg 207, Level 16, State 1, Line 3
Invalid column name 'male'.
任何人都可以告诉我,我在这两方面做错了什么?
再次问好。 我尝试了你发布的查询但是我收到了以下错误:
Msg 245, Level 16, State 1, Line 9
Conversion failed when converting the varchar value 'NA' to data type int.
相反,我使用了以下内容,它确实产生了相同的结果(381行):
select ["Max Weight"]
from dbo.animaldata
where ["Max Weight"] > '5' AND ["Max Weight"]!='N/A'
select ["Max Weight"]
from dbo.animaldata
where ["Max Weight"] > '5'
问题已解决,我将留待将来参考。问候Panos
此致 帕诺斯
答案 0 :(得分:2)
1)“最大重量”栏中的值为“NA”。所以Sql server无法将其转换为int。
2)应该在[“性别”] =“男性”的地方
答案 1 :(得分:0)
select ["Max Weight"]
from dbo.animaldata
where ["Max Weight"]>5 AND ["Max Weight"]!='N/A'