Этот баннер — требование Роскомнадзора для исполнения 152 ФЗ.
«На сайте осуществляется обработка файлов cookie, необходимых для работы сайта, а также для анализа использования сайта и улучшения предоставляемых сервисов с использованием метрической программы Яндекс.Метрика. Продолжая использовать сайт, вы даёте согласие с использованием данных технологий».
Политика конфиденциальности
|
|
|
Columns_UPDATE()
|
|||
|---|---|---|---|
|
#18+
Reschenie problemi ot Microsoft, vrode rabotaet The example provided in SQL Server Books Online of the use of the COLUMNS_UPDATED() clause in a CREATE TRIGGER statement is correct if the table on which the trigger is placed has no more than eight columns. The bits within a byte of the varbinary returned by COLUMNS_UPDATED() are to be read from right to left. So, if you wish to check if columns 2, 3, or 4 have been updated, the correct bitmask to use is 0x0E (binary 00001110, decimal 14). However, if there are more than eight columns, the COLUMNS_UPDATED() function returns the bytes in order from left to right, with the least significant byte being the leftmost. The leftmost byte will contain information about columns 1 through 8, the second byte will contain information about columns 9 through 16, and so on. If there were nine columns in the table and you want to check if columns 2, 3, or 4 have been updated, the correct bitmask to use is 0x0E00 (decimal 3584). Since the bitwise operator only works on 32-bit integers, you may have difficulty checking a table with more than 32 columns. The correct bitmask to check if columns 3, 5, and 9 have changed when there are 16 columns or less is 0x1401 (decimal 5121). The correct bitmask is 0x140100 if there are 24 columns or less, 0x14010000 if 32 columns or less, and so on. Therefore, if there are more than eight columns, you will need to use SUBSTRING to extract the bytes separately: USE Northwind DROP TRIGGER tr1 GO CREATE TRIGGER tr1 ON Customers FOR UPDATE AS IF ( (SUBSTRING(COLUMNS_UPDATED(),1,1)=power(2,(3-1))+ power(2,(5-1))) AND (SUBSTRING(COLUMNS_UPDATED(),2,1)=power(2,(1-1)))) PRINT 'Columns 3, 5 and 9 updated' GO UPDATE Customers SET ContactName=ContactName, Address=Address, Country=Country GO ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 01.08.2001, 12:26 |
|
||
|
Columns_UPDATE()
|
|||
|---|---|---|---|
|
#18+
Ну да, это где-то в последних апдейтах документации добавили, что меня порадовало . Аналогичное решение (да еще в 2 или 3 вариантах) и более универсальное было в конце концов приведено на нашем форуме, когда эта проблема обсуждалась месяца 2 назад . ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 01.08.2001, 12:31 |
|
||
|
Columns_UPDATE()
|
|||
|---|---|---|---|
|
#18+
Да, еще обратите внимание - пример от M$ рассчитан опять же на ограниченное количество колонок (как бы не соврать, на 16). С увеличением количества полей вы столкнетесь с той же самой проблемой, что и раньше. Придется добавить еще один substring и т.д. Проще сразу написать триггер, который будет это учитывать. У меня он получился в свое время несколько громоздким, зато универсальным. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 01.08.2001, 12:35 |
|
||
|
|

start [/forum/topic.php?fid=46&msg=32010872&tid=1825980]: |
0ms |
get settings: |
11ms |
get forum list: |
16ms |
check forum access: |
2ms |
check topic access: |
2ms |
track hit: |
23ms |
get topic data: |
10ms |
get forum data: |
2ms |
get page messages: |
44ms |
get tp. blocked users: |
1ms |
| others: | 218ms |
| total: | 329ms |

| 0 / 0 |
