-- SELECT directly into local variables: >DECLARE <some regular (non-table) variables> > >SELECT > @variable1 = <column1>, > @variable2 = <column2>, > ... > >-- Troubles with this approach: >-- 1. Some of the variables are TEXT, which is not allowed >-- 2. Since some values may be NULL, comparisons used later have to be wrapped in ISNULL() >-- which is a nuisance.>So, on to attempt #3 (which works fine):
-- SELECT to see if old and new values are the same: > >SELECT > ... > FROM <table> > WHERE pkey = @pkey > AND columnvalue = @newcolumnvalue > >-- no special handling needed for NULLs, just a regular SELECT >-- need "AND columnvalue LIKE @newcolumnvalue" for TEXT comparisons > >IF @@ROWCOUNT = 0 >-- New value is different from current one in table >-- IF @@ROWCOUNT = 1, new value is the same as current one in tableYes, it's a nuisance to work with text fields. Fortunatelly, MS in SQL 2005 we can use varchar columns w/o 8000 limit.