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?

  • Because you assign the updated values from a table to a single variable, it will still be possible to get the wrong results. The update on the table could result in multiple rows. Only the last updated row will be visible in the variable.

    So the basic of your solution is not correct. Do not assign multiple rows to a single variable. If you really need to assign an updated value to the variable, at least use the TOP 1 clause in combination with an ORDER BY. This will guarantee the row to be returned. Or apply a WHERE clause that will return a single row.

    ** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **