• You can use Dynamic SQL to handle the scenario

    But, be really careful about SQL Injection and take necessary steps to avoid it

    CREATE PROCEDURE dbo.usp_ShowExpressionResults

    (

    @Expression NVARCHAR(MAX)

    )

    AS

    BEGIN

    SET @Expression = 'SELECT ' + @Expression + ' AS Result'

    EXECUTE sp_executesql @Expression

    END


    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden
    http://www.sqlservercentral.com/articles/Best+Practices/61537/