Okay, so i'm writing a program where a user can input "Selects" on what data they are looking for, and the server returns a value of we have XX many.i've ran into a bit of a wall, the whole time i've basically planned on coding this so that every select the user adds, gets tacked on the back of whatever select there is. so as the user goes though the selection process, the program builds a query.well then when i pass the query to the sqlserver, via ASP.net. it wont work. it looks as though you can only use variables in SQL for certain parts of a query, is that correct?maybe reading the code will give you a better idea of what i was trying to accomplishworking code:DECLARE @querycode VARCHAR(30)SET @querycode ='RI'SELECT state_abbrv, COUNT(state_abbrv) AS KountFROM ResultsWHERE state_abbrv=@querycodegroup by state_abbrvorder by state_abbrv
code i was trying to use:DECLARE @querycode VARCHAR(30)SET @querycode =" (RTRIM(county_name) + ', ' + state_abbrv) IN ('KENT, RI')"SELECT state_abbrv, COUNT(state_abbrv) AS KountFROM ResultsWHERE @querycodeANY help would be OUT STANDING!P.S. the error i get: An expression of non-boolean type specified in a context where a condition is expected, near '@querycode'.