By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,806 Members | 1,787 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,806 IT Pros & Developers. It's quick & easy.

How to fire a trigger without changing table data

P: n/a
I have tables that I want to fire either an update or insert trigger on.

I could write a script containing a long list of inserts but I'm looking for
something simpler. Would isql work? Any special conditions to get it to
work?

I've tried tricks like 'update x set col = col' or 'update x set col = col +
'' '

All the alternatives seem to have problems. Any ideas?


----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Mar 28 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Try:

update MyTable
set
Col1 = 'x'
where
1 = 2

--
Tom

----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com
..
"John Smith" <no****@nowhere.com> wrote in message
news:11**************@sp6iad.superfeed.net...
I have tables that I want to fire either an update or insert trigger on.

I could write a script containing a long list of inserts but I'm looking for
something simpler. Would isql work? Any special conditions to get it to
work?

I've tried tricks like 'update x set col = col' or 'update x set col = col +
'' '

All the alternatives seem to have problems. Any ideas?


----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet
News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+
Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----

Mar 28 '06 #2

P: n/a

"Tom Moreau" <to*@dont.spam.me.cips.ca> wrote in message
news:SL******************@news20.bellglobal.com...
Try:

update MyTable
set
Col1 = 'x'
where
1 = 2


Thanks, but it doesn't work.

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Mar 28 '06 #3

P: n/a
> Thanks, but it doesn't work.

The script Tom posted works for me: Please expand on what you mean by 'it
doesn't work'.

CREATE TABLE MyTable(Col1 int)
GO

CREATE TRIGGER TR_MyTable
ON MyTable FOR INSERT, UPDATE AS
PRINT 'Trigger fired'
GO

UPDATE MyTable
SET Col1 = 'x'
WHERE 1 = 2
GO

DROP TABLE MyTable
GO

--
Hope this helps.

Dan Guzman
SQL Server MVP

"John Smith" <no****@nowhere.com> wrote in message
news:11**************@sp6iad.superfeed.net...

"Tom Moreau" <to*@dont.spam.me.cips.ca> wrote in message
news:SL******************@news20.bellglobal.com...
Try:

update MyTable
set
Col1 = 'x'
where
1 = 2


Thanks, but it doesn't work.
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet
News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+
Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption
=----

Mar 28 '06 #4

P: n/a

"Dan Guzman" <gu******@nospam-online.sbcglobal.net> wrote in message
news:_s*****************@newssvr27.news.prodigy.ne t...
Thanks, but it doesn't work.


The script Tom posted works for me: Please expand on what you mean by 'it
doesn't work'.


Thanks for the help. The problem was due to NULL values in some columns.

The trigger was firing but not changing data.

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Mar 28 '06 #5

P: n/a
>>The trigger was firing but not changing data.
Thats what your question says

Madhivanan

Mar 28 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.