Question

SELECT 1 
FROM geo_locationInfoMajor_tbl 
WHERE geo_locationInfoM_taluka IN(SELECT * from #temp

I have created a temp table which gets its values from the front end.. using a function I insert values into the temp table... Now the data in the temp table is mixed... it can be integer or varchar.. when I pass only int or varchar into the temp table it is fine. but if the output is mixed the query throws an error.. how to deal with this? Conversion failed when converting the varchar value 'English' to data type int.

this is fine-->

#temp
1

this is not-->

1
English
Was it helpful?

Solution

How many values do you have in you temp table? if you want to use the IN clause you should only use one column that is identical with your geo_locationInfoMajor_tbl.

try this:

SELECT * FROM geo_locationInfoMajor_tbl 
WHERE geo_locationInfoM_taluka IN (SELECT geo_locationInfoM_taluka from #temp)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top