Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
SQLIsTheDevil
Posting Yak Master
177 Posts |
Posted - 2009-10-01 : 11:13:09
|
Hey all,I have a question regarding triggers. When I create a trigger, it gets permenantly attached to the table in question, is that right? In other words, it's like creating a stored procedure, no different, correct?Thank you. |
|
SQLIsTheDevil
Posting Yak Master
177 Posts |
Posted - 2009-10-01 : 11:25:24
|
What I'm trying to do is insert a query into, say, Table A from server-side code and use a trigger to check if that row was actually inserted into Table A. If it wasn't, record the exact ad-hoc insert query used into, say, Table B for error-checking. Number one, don't know if this is possible. Two, it has to be for a specific insert query, not every single insert statement.Thank you. |
|
|
X002548
Not Just a Number
15586 Posts |
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2009-10-01 : 13:34:17
|
quote: Originally posted by SQLIsTheDevil What I'm trying to do is insert a query into, say, Table A from server-side code and use a trigger to check if that row was actually inserted into Table A. If it wasn't, record the exact ad-hoc insert query used into, say, Table B for error-checking. Number one, don't know if this is possible. Two, it has to be for a specific insert query, not every single insert statement.Thank you.
Why do you think the insert will fail in the first place? |
|
|
X002548
Not Just a Number
15586 Posts |
|
SQLIsTheDevil
Posting Yak Master
177 Posts |
Posted - 2009-10-01 : 14:19:37
|
Hey Brett,What do you mean by shouldn't allow dynamic sql? I may just use a stored procedure to execute the insert query and setup a trigger when the query is executed. Then, I can check the "inserted" table (i.e. select * from inserted...). Sounds a lot less complex than using ad-hoc queries, me thinks. |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|
|
|
|