• I know the point you were trying to get across, but using sp_executesql is not needed to print the value of the variable. It could simply be written as follows.

    DECLARE @quotedvar nvarchar(100)

    SET @quotedvar = 'O''Neil'

    PRINT @quotedvar