2

Conversion failed when converting the var char value '10, 11, 12, 60, 61, 111, 143, 144' to data type int.

Master Details is var char contains 'list user, add user,list master,add master' value and ID as int, User Access column is Var char containing '10, 11, 12, 60, 61, 111, 143, 144' value

Select Master Details 
from Master information 
where ID IN (SELECT User Access 
             FROM User Access Details where User ID = 22)
Mahmoud Gamal
  • 78,257
  • 17
  • 139
  • 164
  • 2
    You are violating rules of 1NF in your database design - and you should try to not do that. Every field in a database should carry an atomic Information. – TGlatzer Dec 16 '13 at 11:23
  • i used cast function as Select ID,MasterDetails from Masterinformation where CAST(ID AS VARCHAR(15)) IN (select CAST(UserAccess AS VARCHAR(15)) FROM UserAccessDetails where UserID = 22) – user3107055 Dec 16 '13 at 11:24
  • You really should feel bad about that "solution". And btw.. 11 is in 114857 - that might be a Problem sometime... – TGlatzer Dec 16 '13 at 11:30

1 Answers1

1

Make sure that you have same column type in both your tables.
Otherwise use cast or convert to make it of same type in your query.

also you should use single column in you inner query or use [] for column name having spaces in your column name.

SELECT [User Access] 
         FROM User Access Details where User ID = 22

MSDN link for cast and convert

Some links

  1. sql how to cast a select query
Community
  • 1
  • 1
शेखर
  • 17,412
  • 13
  • 61
  • 117