是否可以在 UPDATE() 中使用变量来检查列是否更新?
这是我的示例代码:
DECLARE @ColumnCount int
DECLARE @ColumnCounter int
DECLARE @ColumnName nvarchar(MAX)
SET @ColumnCounter = 0
SELECT @ColumnCount = COUNT(c.COLUMN_NAME) FROM INFORMATION_SCHEMA.COLUMNS c WHERE c.TABLE_NAME = 'Province'
WHILE @ColumnCount >= @ColumnCounter
BEGIN
SELECT @ColumnName = c.COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS c WHERE c.TABLE_NAME = 'Province' AND c.ORDINAL_POSITION = @ColumnCounter
IF (UPDATE(@ColumnName))
SET @ColumnCounter = @ColumnCounter + 1
END