dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: be done with trigger (SQL 2000) ??

  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    be done with trigger (SQL 2000) ??

    [Originally posted by m.posseth]

    scenario :

    i have a table with 2 fields one is a bit field (true - false ) the other is a smallint field

    i want to know if it is possible to write a trigger that will set the integer field to 0
    if the bit operator is set to 0 ( false )


    if possible could someone show a small example ?? (or explain )

  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re: be done with trigger (SQL 2000) ??

    [Originally posted by FreeVBCode.com]

    This assumes you have an identify field in there, named ID.

    CREATE TRIGGER [myTrigger] ON [dbo].[MyTable]
    FOR INSERT, UPDATE
    AS
    DECLARE @b bit
    DECLARE @i int
    SELECT @B = bitfield from Inserted

    IF @B=0
    SELECT @i = ID from Inserted
    UPDATE MYTABLE SET INTFIELD=0 WHERE ID=@i

  3. #3
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re: be done with trigger (SQL 2000) ??

    [Originally posted by m.posseth@work]

    thanks that was great ,,,


    it did exactly what i wanted ,,,

    it is time for me to buy a good SQL 2000 Book :-)
    triggers are really great ( never used them before )

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center