• (cs) in reply to anonymous
    anonymous:
    Can anyone deconstruct what it's attempting to do BEFORE it commits seppuku if it fails?
    WHEN (SELECT COUNT(1) FROM deleted) = 0
    THEN N'i'   -- the Knights Who Say N'i' were here
    An UPDATE is handled as a deletion followed by an insertion. When a trigger is active, two virtual tables are available for use: inserted and deleted. DELETE statements fill the deleted table with the rows which are to be deleted. INSERT statements fill the inserted table with rows which are to be inserted. And UPDATE statements fill both tables, deleted with the original version of the rows, inserted with the changed version of the rows. If the deleted table contains 0 rows, this is an INSERT, otherwise it's an UPDATE.
  • frustrated dba (unregistered) in reply to NMe
    NMe:
    I don't really see a huge problem considering what it's apparently used for. It looks like an automated audit log. What should you do when logging fails? Log it somewhere else instead? How would you consolidate that back into your database properly, especially since a select is required to get the proper data in the first place?

    Throwing an error back to the user would also not make sense. Why would you throw an error to the user if the changes they made worked perfectly but you failed to log the fact that they changed things?

    Of course a better way to do this would be to handle the audit log in your framework where any query is automatically logged (and in which you can send a message to support if something goes wrong), but lacking that I don't think this is that terrible of a solution.

    Why is it, why is it, that I always end up working with you and your best friend?

  • (cs) in reply to Pawprint
    Pawprint:
    anonymous:
    Can anyone deconstruct what it's attempting to do BEFORE it commits seppuku if it fails?
    WHEN (SELECT COUNT(1) FROM deleted) = 0
    THEN N'i'   -- the Knights Who Say N'i' were here
    An UPDATE is handled as a deletion followed by an insertion. When a trigger is active, two virtual tables are available for use: inserted and deleted. DELETE statements fill the deleted table with the rows which are to be deleted. INSERT statements fill the inserted table with rows which are to be inserted. And UPDATE statements fill both tables, deleted with the original version of the rows, inserted with the changed version of the rows. If the deleted table contains 0 rows, this is an INSERT, otherwise it's an UPDATE.
    Well this explains only half the mystery. The remaining be: Why say N'i' here?

    Turns out this is a bonus WTF: What is the meaning of the prefix N in T-SQL statements?

    You may have seen Transact-SQL code that passes strings around using an N prefix. This denotes that the subsequent string is in Unicode (the N actually stands for National language character set). Which means that you are passing an NCHAR, NVARCHAR or NTEXT value, as opposed to CHAR, VARCHAR or TEXT.
    Now check the declaration of that variable!
  • (cs) in reply to Rorre
    Rorre:
    Fortunately, in most cases the Catch will fail since in a proper system the calling user won't have permission to drop triggers.

    One would hope.

    Now, that's funny.

  • (cs) in reply to no laughing matter
    no laughing matter:
    Pawprint:
    anonymous:
    Can anyone deconstruct what it's attempting to do BEFORE it commits seppuku if it fails?
    WHEN (SELECT COUNT(1) FROM deleted) = 0
    THEN N'i'   -- the Knights Who Say N'i' were here
    An UPDATE is handled as a deletion followed by an insertion. When a trigger is active, two virtual tables are available for use: inserted and deleted. DELETE statements fill the deleted table with the rows which are to be deleted. INSERT statements fill the inserted table with rows which are to be inserted. And UPDATE statements fill both tables, deleted with the original version of the rows, inserted with the changed version of the rows. If the deleted table contains 0 rows, this is an INSERT, otherwise it's an UPDATE.
    Well this explains only half the mystery. The remaining be: Why say N'i' here?

    Turns out this is a bonus WTF: What is the meaning of the prefix N in T-SQL statements?

    You may have seen Transact-SQL code that passes strings around using an N prefix. This denotes that the subsequent string is in Unicode (the N actually stands for National language character set). Which means that you are passing an NCHAR, NVARCHAR or NTEXT value, as opposed to CHAR, VARCHAR or TEXT.
    Now check the declaration of that variable!

    I see the abuse of that too many times:

    SET @Query = N'SELECT Username ' +
       N' FROM Users ' +
       N' WHERE UserID = ' +
       @UserID;
    

    Bonus points if you can figure out the hidden WTF in that code.

  • DBA DUDE (unregistered) in reply to chubertdev

    I don't see a wtf, I just see something that won't compile in T-SQL. If @UserID is a string, it needs to be quoted before the query can be executed. If @UserID is a number, it has to be cast as a string. Well, I guess there is a third case where @UserID is typed as a string, but holds a number. In that case, the code would compile, it would execute, and I would scream.

  • Blaney Krichen (unregistered) in reply to Roby McAndrew
    Roby McAndrew:
    If code fails it is right and proper that it commits Sudoku
    FTFY
  • anonymous (unregistered) in reply to DBA DUDE
    DBA DUDE:
    Well, I guess there is a third case where @UserID is typed as a string, but holds a number. In that case, the code would compile, it would execute, and I would scream.
    ...not to mention that someone might have the UserID "1;DROP TABLE Users;".
  • (cs) in reply to DBA DUDE
    DBA DUDE:
    I don't see a wtf, I just see something that won't compile in T-SQL. If @UserID is a string, it needs to be quoted before the query can be executed. If @UserID is a number, it has to be cast as a string. Well, I guess there is a third case where @UserID is typed as a string, but holds a number. In that case, the code would compile, it would execute, and I would scream.

    That would be the WTF. Inferring that it does compile, @UserID would be a string. And yes, you should scream at something like this.

  • (cs)

    We are the best producer of Real Registered and High Quality fake documents. With over 6million of out documents circulating over the world. [email protected] We offer only original Registered high-quality passports, driver’s licenses, ID cards, stamps and other products for a number of countries like: USA, Australia, Belgium, Brazil, Canada, Italia, Finland, France, Germany, Israel, Mexico, Netherlands, South Africa, Spain, United Kingdom. This list is not full.

    To get the additional information and place the order just email

    BUY PASSPORT BRITISH(UK) FOR SALE DIPLOMATIC CANADIAN FALSE ID CARD ONLINE UNITED STATES(US) REAL AND FAKE ID CARD SELL DRIVERS LICENSE

    Contact e-mails: [email protected]

    General support: [email protected]

    Technical support: [email protected] feel free to contact via email ——————————————- Keywords:

    Real/fake USA(United States) passports, Real/fake Australian passports, Real/fake Belgium passports, Real/fake Brazilian(Brazil) passports, Real/fake Canadian(Canada) passports, Real/fake Finnish(Finland) passports, Real/fake French(France) passports, Real/fake German(Germany) passports, Real/fake Dutch(Netherland/Holland) passports, Real/fake Israel passports, Real/fake UK(United Kingdom) passports, Real/fake Spanish(Spain) passports, Real/fake Mexican(Mexico) passports, Real/fake South African passports. fake Australian driver licenses, fake Canadian driver licenses, fake French(France) driver licenses, fake Dutch(Netherland/Holland) driving licenses, fake German(Germany) driving licenses, fake UK(United Kingdom) driving licenses, fake Diplomatic passports, false USA(United States) passports, false Australian passports, false Belgium passports, false Brazilian(Brazil) passports, false Canadian(Canada) passports, false Finnish(Finland) passports, false French(France) passports, false German(Germany) passports, false Dutch(Netherland/Holland) passports, false Israel passports, false UK(United Kingdom) passports, false Spanish(Spain) passports, false Mexican(Mexico) passports, false South African passports. false Australian driver licenses, false Canadian driver licenses, false French(France) driver licenses, false Dutch(Netherland/Holland) driving licenses, false German(Germany) driving licenses, false UK(United Kingdom) driving licenses, false Diplomatic passports, Camouflage passports, passport Duplicates, fake USA(united States) passports for sale, fake Australian passports for sell, fake Belgium passports for sell, fake Brazilian(Brazil) passports for sell, fake Canadian(Canada) passports for sell, fake Finnish(Finland) passports for sell, fake French(France) passports for sell, fake German(Germany) passports for sell, fake Dutch(Netherland/Holland) passports for sell, fake Israel passports for sell, fake UK(United Kingdom) passports for sell, fake Spanish(Spain) passports for sell, fake Mexican(Mexico) passports for sell, fake South African passports for sell, fake Australian driver licenses for sell, fake Canadian driver licenses for sell, fake Diplomatic passports for sell, false USA(united States) passports for sale, false Australian passports for sell, false Belgium passports for sell, false Brazilian(Brazil) passports for sell, false Canadian(Canada) passports for sell, false Finnish(Finland) passports for sell, false French(France) passports for sell, false German(Germany) passports for sell, false Dutch(Netherland/Holland) passports for sell, false Israel passports for sell, false UK(United Kingdom) passports for sell, false Spanish(Spain) passports for sell, false Mexican(Mexico) passports for sell, false South African passports for sell, false Australian driver licenses for sell, Camouflage passports for sale, passport Duplicates for sale. order fake passports, order false passports, order novelty passports, order fake driver license, order false driver license, order novelty driver license, order Diplomatic passports, obtain fake passports, obtain false passports, obtain novelty passports, obtain fake driving licence, obtain false driver license, obtain novelty driver license, obtain Diplomatic passports, purchase fake passports, purchase false passports, purchase novelty passports, purchase fake driver license, purchase false driver license, purchase novelty driver license, purchase Diplomatic passports, sell fake passports, sell false passports, sell novelty passports, sell fake driving licence, sell false driver license, sell novelty driver license, get fake passports, get false passports, get novelty passports, get fake driving licence, get false driving license, get novelty driver license, get Diplomatic passports, make fake passports, make false passports, make novelty passports, make fake driving license, make false driving license, make novelty driver license, make Diplomatic passports,

    fake passport of Afghanistan fake passport of Albania fake passport of Algeria fake passport of Andorra fake passport of Angola fake passport of Argentina fake passport of Armenia fake passport of Australia fake passport of Austria fake passport of Bahrain fake passport of Bangladesh fake passport of Barbados fake passport of Belarus fake passport of Belgium fake passport of Belize fake passport of Benin fake passport of Bhutan fake passport of Bolivia fake passport of Bosnia Herzegovina fake passport of Brazil fake passport of Brunei fake passport of Bulgaria fake passport of Burkina fake passport of Burundi fake passport of Cambodia fake passport of Cameroon fake passport of Canada fake passport of Cape Verde fake passport of Central African Rep fake passport of Chad fake passport of Chile fake passport of China fake passport of Colombia fake passport of Comoros fake passport of Congo fake passport of Congo {Democratic Rep} fake passport of Costa Rica fake passport of Croatia fake passport of Cuba fake passport of Cyprus fake passport of Czech Republic fake passport of Denmark Contact me via email [email protected]

  • (cs)

    We are the best producer of Real Registered and High Quality fake documents. With over 6million of out documents circulating over the world. [email protected] We offer only original Registered high-quality passports, driver’s licenses, ID cards, stamps and other products for a number of countries like: USA, Australia, Belgium, Brazil, Canada, Italia, Finland, France, Germany, Israel, Mexico, Netherlands, South Africa, Spain, United Kingdom. This list is not full.

    To get the additional information and place the order just email

    BUY PASSPORT BRITISH(UK) FOR SALE DIPLOMATIC CANADIAN FALSE ID CARD ONLINE UNITED STATES(US) REAL AND FAKE ID CARD SELL DRIVERS LICENSE

    Contact e-mails: [email protected]

    General support: [email protected]

    Technical support: [email protected] feel free to contact via email ——————————————- Keywords:

    Real/fake USA(United States) passports, Real/fake Australian passports, Real/fake Belgium passports, Real/fake Brazilian(Brazil) passports, Real/fake Canadian(Canada) passports, Real/fake Finnish(Finland) passports, Real/fake French(France) passports, Real/fake German(Germany) passports, Real/fake Dutch(Netherland/Holland) passports, Real/fake Israel passports, Real/fake UK(United Kingdom) passports, Real/fake Spanish(Spain) passports, Real/fake Mexican(Mexico) passports, Real/fake South African passports. fake Australian driver licenses, fake Canadian driver licenses, fake French(France) driver licenses, fake Dutch(Netherland/Holland) driving licenses, fake German(Germany) driving licenses, fake UK(United Kingdom) driving licenses, fake Diplomatic passports, false USA(United States) passports, false Australian passports, false Belgium passports, false Brazilian(Brazil) passports, false Canadian(Canada) passports, false Finnish(Finland) passports, false French(France) passports, false German(Germany) passports, false Dutch(Netherland/Holland) passports, false Israel passports, false UK(United Kingdom) passports, false Spanish(Spain) passports, false Mexican(Mexico) passports, false South African passports. false Australian driver licenses, false Canadian driver licenses, false French(France) driver licenses, false Dutch(Netherland/Holland) driving licenses, false German(Germany) driving licenses, false UK(United Kingdom) driving licenses, false Diplomatic passports, Camouflage passports, passport Duplicates, fake USA(united States) passports for sale, fake Australian passports for sell, fake Belgium passports for sell, fake Brazilian(Brazil) passports for sell, fake Canadian(Canada) passports for sell, fake Finnish(Finland) passports for sell, fake French(France) passports for sell, fake German(Germany) passports for sell, fake Dutch(Netherland/Holland) passports for sell, fake Israel passports for sell, fake UK(United Kingdom) passports for sell, fake Spanish(Spain) passports for sell, fake Mexican(Mexico) passports for sell, fake South African passports for sell, fake Australian driver licenses for sell, fake Canadian driver licenses for sell, fake Diplomatic passports for sell, false USA(united States) passports for sale, false Australian passports for sell, false Belgium passports for sell, false Brazilian(Brazil) passports for sell, false Canadian(Canada) passports for sell, false Finnish(Finland) passports for sell, false French(France) passports for sell, false German(Germany) passports for sell, false Dutch(Netherland/Holland) passports for sell, false Israel passports for sell, false UK(United Kingdom) passports for sell, false Spanish(Spain) passports for sell, false Mexican(Mexico) passports for sell, false South African passports for sell, false Australian driver licenses for sell, Camouflage passports for sale, passport Duplicates for sale. order fake passports, order false passports, order novelty passports, order fake driver license, order false driver license, order novelty driver license, order Diplomatic passports, obtain fake passports, obtain false passports, obtain novelty passports, obtain fake driving licence, obtain false driver license, obtain novelty driver license, obtain Diplomatic passports, purchase fake passports, purchase false passports, purchase novelty passports, purchase fake driver license, purchase false driver license, purchase novelty driver license, purchase Diplomatic passports, sell fake passports, sell false passports, sell novelty passports, sell fake driving licence, sell false driver license, sell novelty driver license, get fake passports, get false passports, get novelty passports, get fake driving licence, get false driving license, get novelty driver license, get Diplomatic passports, make fake passports, make false passports, make novelty passports, make fake driving license, make false driving license, make novelty driver license, make Diplomatic passports,

    fake passport of Afghanistan fake passport of Albania fake passport of Algeria fake passport of Andorra fake passport of Angola fake passport of Argentina fake passport of Armenia fake passport of Australia fake passport of Austria fake passport of Bahrain fake passport of Bangladesh fake passport of Barbados fake passport of Belarus fake passport of Belgium fake passport of Belize fake passport of Benin fake passport of Bhutan fake passport of Bolivia fake passport of Bosnia Herzegovina fake passport of Brazil fake passport of Brunei fake passport of Bulgaria fake passport of Burkina fake passport of Burundi fake passport of Cambodia fake passport of Cameroon fake passport of Canada fake passport of Cape Verde fake passport of Central African Rep fake passport of Chad fake passport of Chile fake passport of China fake passport of Colombia fake passport of Comoros fake passport of Congo fake passport of Congo {Democratic Rep} fake passport of Costa Rica fake passport of Croatia fake passport of Cuba fake passport of Cyprus fake passport of Czech Republic fake passport of Denmark Contact me via email [email protected]

  • C (unregistered)

    I just tested, and the code below will happily drop itself:

    CREATE TRIGGER dbo.test_Self_Destruct ON dbo.tmp_a_test AFTER INSERT
    AS
    BEGIN
    	drop TRIGGER dbo.test_Self_Destruct
    END
  • Anonymous (unregistered)

    Am I the only one that found the unicorn? Or is it something well known here?

  • anonymous (unregistered) in reply to Anonymous
    Anonymous:
    Am I the only one that found the unicorn? Or is it something well known here?
    The latter thing. Also, view the page source or you'll miss out on some of Remy's wit and wisdom.

Leave a comment on “Dropped Catch”

Log In or post as a guest

Replying to comment #:

« Return to Article