Why do I have different result set between SELECT * and SELECT Column1?
<p>I have a Stored Procedure where I am using a string function in my <code>WHERE</code> in order to pass multiple parameter values.
But why it works fine if I say </p>

<pre><code>WHERE  
   cc.ClassCode IN (SELECT ClassCode 
                    FROM [dbo].[StringOfStringsToTable](@ClassCode, ','))
</code></pre>

<p>But it gives me complete different incorrect result if I say:</p>

<pre><code>WHERE 
    cc.ClassCode  IN (SELECT * 
                      FROM [dbo].[StringOfStringsToTable](@ClassCode, ',')) 
</code></pre>

<p>In both cases <code>@ClassCode = '31439,68189,01239,41894...'</code> the same order of values, whether its <code>SELECT ClassCode FROM</code> or <code>SELECT * FROM</code></p>

<p>What is the logic behind?</p>

<p>Full query:</p>

<pre><code>ALTER PROCEDURE dbo.LossesByStateTest
    @ClassCode nvarchar(max)
AS 
BEGIN
    SELECT      
        pc.Quoteid, pc.PolicyNumber, pc.AccidentDate,
        cc.TransactionEffectiveDate, cc.ClassCode,
        CASE
            WHEN ROW_NUMBER() OVER (PARTITION BY pc.QuoteID, pc.PolicyNumber, cc.AccidentDate ORDER BY (SELECT 0)) = 1 
               THEN pc.PaidLosses 
               ELSE 0
        END  as PaidLosses--,
    FROM
        tblLossesPlazaCommercialAuto pc 
    INNER JOIN
        tblClassCodesPlazaCommercial cc ON pc.PolicyNumber = cc.PolicyNumber 
                                        AND pc.AccidentDate = cc.AccidentDate
                                        AND cc.AccidentDate IS NOT NULL
    --WHERE cc.ClassCode   IN (SELECT ClassCode FROM [dbo].[StringOfStringsToTable](@ClassCode,','))    --Works fine
    WHERE  
        cc.ClassCode IN (SELECT * FROM [dbo].[StringOfStringsToTable](@ClassCode, ','))     --- doesn't work
END 
</code></pre>

<p>Function is below:</p>

<pre><code>ALTER FUNCTION [dbo].[StringOfStringsToTable]
    (@Strings varchar(8000),
     @Separator char(1))
RETURNS @StringTable TABLE (String varchar(500))
AS
BEGIN
    DECLARE @String varchar(500), @Pos int

    SET @Strings = LTRIM(RTRIM(@Strings))+ @Separator
    SET @Pos = CHARINDEX(@Separator, @Strings, 1)

    WHILE @Pos &gt; 0
    BEGIN
        SET @String = LTRIM(RTRIM(LEFT(@Strings, @Pos - 1)))

        IF @String &lt;&gt; '' 
           INSERT INTO @StringTable VALUES (@String)

        SET @Strings = RIGHT(@Strings, LEN(@Strings) - @Pos)
        SET @Pos = CHARINDEX(@Separator, @Strings, 1)
    END

    RETURN
END
</code></pre>

<p>@scsimon I am so sorry. It didnt work because the way I supplied my parameter values in SP was written in a column and the apostrophe was on the other line. I added a picture above. 
Incorect way:</p>

<p><a href="https://i.stack.imgur.com/67upz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/67upz.png" alt="enter image description here"></a></p>

<p>See where the last apostrophe?</p>

<p>And this is correct way:</p>

<p><a href="https://i.stack.imgur.com/kWqQJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kWqQJ.png" alt="enter image description here"></a></p>