• Thanks for the question.

    It may sound stupid to the more experienced users, but I don't understand why the following code is not working (using SQL Server 2005; pasted just my amended query--you'll need the original one, too):

    --Select 3

    SET @inputValue = '''Hardy''' + ', ' + '''Rocky'''

    select @inputValue -- added to view the output of the variable

    SELECT * FROM @student WHERE StudentName IN (@inputValue) -- not working

    Because if you write out the query without the variable, it will return the expected 2 records.

    SELECT * FROM @student WHERE StudentName IN ('Hardy', 'Rocky') -- working OK

    Any hints / explanations are welcome.

    Thanks in advance,

    Michael