Ask the question: does Sql Server have a row level trigger. Answer: it depends. From the point of view of application development how in the world can the answer possibly be ambiguous? Well lets back up and look at the Update statement. From Sql Server 2005 bol: Using UPDATE with the FROM Clause 'The results of an UPDATE statement are undefined if the statement includes a FROM clause that is not specified in such a way that only one value is available for each column occurrence that is updated, that is if the UPDATE statement is not deterministic'. Ok what is really the rational for even keeping this 'proprietary' syntax? Since it is inherently non-deterministic why even offer it to developers most of whom do not understand but the simplest of sql. After all Sql Server is explicitly relinquishing responsibility for the integrity of the Update and making the user responsible. Shouldn't the idea of a database be the other way around? Ok now lets move to the trigger. From bol under the topic: Multirow Considerations for DML Triggers: 'When you write the code for a DML trigger, consider that the statement that causes the trigger to fire can be a single statement that affects multiple rows of data, instead of a single row.' Does this sound familiar? Of course it does. The same non-determinism of the FROM clause in Update now reappears in the insert table of the trigger. But of course it is not presented as a 'trigger is inherently undefined'. No, now the undefined nature of the trigger is called 'a Multirow consideration'. And again the server reliquishes responsibility of integrity and puts it in the hands of the user. Well lets get real. There is no such thing as a multirow trigger. From an applications standpoint the largest scope of a trigger is a row. The so called multirow trigger is an example of what happens when users don't scrutinize what nonsense is thrown their way. Instead of getting rid of a stupid idea in Update using a FROM it was instead extended to a trigger. It was simply an easy and expedient thing to do. But it was shameful and lazy too. Lack of integrity is based on lack of character. But it is equally disappointing that more users do not complain and demand the integrity that a database should offer. Sql Server can do much, much better. But, like E.T., users must phone home.
Dataphor SQL RAC (Relational Application Companion)
A site of hope for those looking for a true relational database system
- a one-one requirement constraint with dataphor (1)
- anatomy of sql server part I - what is a stored procedure (1)
- anatomy of sql server part II - the unit test as part of the database (1)
- anatomy of sql server part III - what does deferred name resolution really mean (1)
- censoring sql posts (1)
- creating an opposite constraint in dataphor (1)
- dataphor (2)
- Dataphor (7)
- dataphor # 13 a table as a parameter (1)
- dataphor - download and start working with it (1)
- dataphor - fixed sized word segments (1)
- dataphor # 10 sql mythology (1)
- dataphor # 11 string differences (1)
- dataphor # 12 trimming a string (1)
- dataphor # 14 sql the meaning of Update..From (1)
- dataphor # 15 views with substance (1)
- dataphor # 16 inclusive vs exclusive solutions (1)
- dataphor # 17 a visual look at ranking queries (1)
- dataphor # 18 data scrubbing using lists (1)
- dataphor # 19 create intervals over strings (1)
- dataphor # 20 browsing an sql window (1)
- dataphor # 21 an example of relational division (1)
- dataphor # 22 reusable procedures (1)
- dataphor # 23 repley to Michel (1)
- dataphor # 24 basics of the table type (1)
- dataphor # 25 extending the dense rank function (1)
- dataphor # 26 query a hierarchy with explode (1)
- dataphor # 27 combine strings with Split and Concat (1)
- dataphor # 28 constants and variables or sql and D4 (1)
- dataphor # 29 another example of relational division (1)
- dataphor #1 introduction (1)
- dataphor #2 splitting strings (1)
- dataphor #3 string concatenation (1)
- dataphor #4 comment (1)
- dataphor #5 comment (1)
- dataphor #6 formal definition (1)
- dataphor #7 sql: table this (1)
- dataphor #8 list to table (1)
- dataphor #9 table constraints (1)
- dataphor creating lists in a query (1)
- extracting numbers from a string with dataphor (1)
- jeff modens dynamic crosstabs for sql server (1)
- linq to sql the what and why (1)
- linq to sql as a window of opportunity to sql users (1)
- linq to sql should be important to sql users (1)
- linq to sql vs. older 4GL attempts (1)
- listing missing table item (1)
- Multiple cascade paths to the same table (1)
- RAC (4)
- RAC #1 comment (1)
- RAC #2 example (1)
- RAC #3 finding the Nth number in a string (1)
- RAC #4 Sql Server 2005 ranking functions vs. Rac ranking (1)
- sorting a delimited string by its numerical string parts (1)
- sql an example of extreme implicit conversions (1)
- sql can't handle complicated cascading updates (1)
- sql CTE should be a variable not a value (1)
- sql dense rank for identifying consecutive runs (1)
- sql is there really a table variable (1)
- sql ranking functions explained by relational types (1)
- sql server triggers are best set based (1)
- sql the idea of using substring to simulate lists (1)
- sql the undefined trigger in Sql Server (1)
- sql vs relational on tables (1)
- sql what the sql CTE covers up (1)
- types and procedures (1)
Sunday, October 21, 2007
Sql Server - The Undefined Trigger
Subscribe to:
Post Comments (Atom)
1 comment:
I saw a great deal of helpful information above!
Post a Comment