| Author |
Topic  |
|
|
arkiboys
Flowing Fount of Yak Knowledge
1341 Posts |
Posted - 11/26/2012 : 05:55:04
|
declare @value1 int = 2 declare @value2 int = 4 declare @Allvalues varchar(100) = cast(@value1 as varchar(10)) + ',' + cast(@value2 as varchar(10))
field1 is an int datatype select field1, field2 from tblMain where field1 = @value1 select field1, field2 from tblMain where field1 = @value2
Question: HOw do I get the following to work please? Error is: Conversion failed when converting the varchar value '2, 4' to data type int. select field1, field2 from tblMain where field1 in (@Allvalues)
Thanks |
|
|
bandi
Flowing Fount of Yak Knowledge
India
1451 Posts |
Posted - 11/26/2012 : 06:14:55
|
select field1, field2 from tblMain where ',' + CAST( field1 AS VARCHAR(50)) + ',' LIKE '%,' + @Allvalues + ',%'
-- Chandu |
 |
|
|
arkiboys
Flowing Fount of Yak Knowledge
1341 Posts |
Posted - 11/26/2012 : 06:46:07
|
| Thanks |
 |
|
|
bandi
Flowing Fount of Yak Knowledge
India
1451 Posts |
Posted - 11/26/2012 : 06:47:02
|
quote: Originally posted by arkiboys
Thanks
You are Welcome
-- Chandu |
 |
|
| |
Topic  |
|