141
Comments
  • 14
    Delete without a where clause always looks suspicious and catches the eye. It's waaaay to short for a query.

    Update however ... is another issue.
  • 5
    I always perform an exact select before a delete or update...in the worst case I will know that I screwed up immediately...doh
  • 1
    @Lahsen2016 Guess I was freaking Lucky 😁

    Here you go
    https://devrant.com/rants/982181/...
  • 2
    LOL I had a similar one:
    One day I have executed a cleanup script for my test DB which truncates every table and wondered why it is so slow this time. Executed it again. Well, still slow.
    SHIIIIIIITTT still connected to prod DB. 😁
  • 1
    Do people really do this still?? What happened to doing everything in transactions that you can rollback or commit once you know you did it right?
  • 1
    @nkydeerguy what happened is that:
    1. People are lazy to write "BEGIN TRAN" or whatever.
    2. If you use the "Do not auto-commit transactions" in the GUI, people end up with locked tables because of a stupid SELECT statement that wasn't committed.
  • 0
    @IllSlapU No !! No !! Please Don't !! I'm already having a bad day. Is that you "Lahsen2016" ? You could've chosen better one 😂😂
  • 0
    where is just sugar for let/in ;)
  • 1
    @LeFlawk
    Basic SQL Syntax for CRUD operations (create, read, update, delete)

    INSERT INTO <table name> (<optional field list>) VALUES (<value list>)

    SELECT <field list> FROM <table name> WHERE <condition>

    this one selects fields that match the condition in WHERE. Without a WHERE clause, everything is selected.

    UPDATE <table> SET <feld>=<new value>, <field2> = <new value> WHERE <condition>

    here, the same, rows are updated, and fields get new values, but only the rows that match a condition.
    Forget the WHERE, and all rows get modified and get the same new values for those fields. Basically data loss. For example:

    UPDATE users SET password=<new value> WHERE username='AndSoWeCode'

    So only one user's password will be updated. Forget the "WHERE" clause, and all users have changed passwords.

    DELETE FROM <table name> WHERE <codition>

    This one is simple - deletes rows that match the condition. Forget the WHERE clause, and all rows get deleted.
  • 1
    Just don't test in prod? I also believe there's an extension for SSMS that double checks when you run dangerous queries without a WHERE clause
  • 2
    Or use transactional statements
  • 0
    really cool broo..
Add Comment