Home Forums SQL Server 2008 T-SQL (SS2K8) Is there a way to sort the table after records are inserted? RE: Is there a way to sort the table after records are inserted?

  • You should be able to use a correlated subquery, like so:

    SELECT

    @mystring,

    REPLACE(@mystring, name, value) AS newstring

    FROM (

    SELECT TOP (1) * FROM @tab WHERE @mystring LIKE '%' + name + '%' ORDER BY LEN(name) DESC

    ) AS correlated

    SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.