Hello All,
I'm new to SQL programming and was looking for some help ...
There is an update trigger on a table which does
SELECT * INTO #DELETED FROM DELETED
(so that the old value is captured)initially and later at some point in the logic, the name of the updated column is determined and stored in the variable @UPDTCOLNAME (There are more than 40 columns in the table and we need to figure out what exact column was updated for the row).
The following statements are then executed to determine the old value of the updated column.
SET @SQLQ = N'SELECT @OLD_VALUE = '+@UPDTCOLNAME+' FROM #DELETED WHERE SID = '''+@DEL_SID+''' '
EXEC SP_EXECUTESQL @SQLQ, N'@OLD_VALUE VARCHAR(2000) OUT',@OLD_VALUE OUT
Is there a way I can achieve the same by not using the temporary table #DELETED but actually somehow use the special table DELETED directly. The reason I need this option is because when I send huge updates, lets say 100K records the SELECT * INTO #DELETED FROM DELETED runs into minutes and slows down the processing.
Thanks for any suggestions.
Pfe
I'm new to SQL programming and was looking for some help ...
There is an update trigger on a table which does
SELECT * INTO #DELETED FROM DELETED
(so that the old value is captured)initially and later at some point in the logic, the name of the updated column is determined and stored in the variable @UPDTCOLNAME (There are more than 40 columns in the table and we need to figure out what exact column was updated for the row).
The following statements are then executed to determine the old value of the updated column.
SET @SQLQ = N'SELECT @OLD_VALUE = '+@UPDTCOLNAME+' FROM #DELETED WHERE SID = '''+@DEL_SID+''' '
EXEC SP_EXECUTESQL @SQLQ, N'@OLD_VALUE VARCHAR(2000) OUT',@OLD_VALUE OUT
Is there a way I can achieve the same by not using the temporary table #DELETED but actually somehow use the special table DELETED directly. The reason I need this option is because when I send huge updates, lets say 100K records the SELECT * INTO #DELETED FROM DELETED runs into minutes and slows down the processing.
Thanks for any suggestions.
Pfe