T SQL

  • rhythmk (7/9/2012)


    I got the answer in first click but then I thought what if SQL 2012 get WHERE clause in TRUNCATE command :hehe:

    I pondered that, and tried to think of a way it could be written to only deallocate* selected pages, and couldn't figure out a quick way it could have been implemented.

    Then I wondered if it could have been changed to ignore the erroneous clause... but decided that would create an even larger hue and of course cry. "No No..." I told myself, "the current behaviour is perfect. They couldn't possibly have changed it."

    ---====####====----

    * "Deallocate"... or is there a more proper term for what TRUNCATE does?

  • Very easy question.

    Thanks
    Vinay Kumar
    -----------------------------------------------------------------
    Keep Learning - Keep Growing !!!

  • Thanks for the question Samith. I'm guessing you specified an SQL Server version to avoid problems that occasionally pop up with QotD's that don't specify the version. In this case, it actually made the question less straightforward. But, you likely gathered that from the earlier posts. In summary,

    +57.

    [font="Verdana"]Please don't go. The drones need you. They look up to you.[/font]
    Connect to me on LinkedIn

  • Thomas Abraham (7/10/2012)


    Thanks for the question Samith. I'm guessing you specified an SQL Server version to avoid problems that occasionally pop up with QotD's that don't specify the version. In this case, it actually made the question less straightforward. But, you likely gathered that from the earlier posts. In summary,

    +57.

    +57 + 1

    For a moment I had my doubts and thought "maybe it did change? Surely the QotD wouldn't be this easy. There has to be a catch." But, I went with what I knew and it was right. Thank you for the great question. QotD always gets my day started right. 😀



    Everything is awesome!

  • I'm not sure if it was a trick question or an easy question, but I followed my instincts on the way TRUNCATE works and got it right.

    It's a good way to start the day.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Thomas Abraham (7/10/2012)


    Thanks for the question Samith. I'm guessing you specified an SQL Server version to avoid problems that occasionally pop up with QotD's that don't specify the version. In this case, it actually made the question less straightforward. But, you likely gathered that from the earlier posts. In summary,

    +57.

    To me the question was clear, but specifying the version made me wonder if there had been a change in 2012 with regard to TRUNCATE. So, I ended up doing a little research, just to be sure, before answering.

  • It did make me think seriously about getting a 2012 instance installed in a development/learning mode.

  • Thanks for the straight forward question which only has ONE correct answer. 😛

    Cheers,

    Steve

  • Thank you for the easy question, it also made me think and test about WHERE added to TRUNCATE in SS 2012, but after testing I wondered, would there be a reason to add a WHERE clause to TRUNCATE? Isn't TRUNCATE a quick and easy way to remove all records in a table without condition?

    "El" Jerry.

    "El" Jerry.

    "A watt of Ottawa" - Gerardo Galvan

    To better understand your help request, please follow these best practices.[/url]

  • Nice straight forward easy question. Not certain why adding the server version would cause the answer to be any less clear. Second sentance in BOL for Truncate is;

    TRUNCATE TABLE is similar to the DELETE statement with no WHERE clause

  • good question - cheers

  • EZ PZ

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • SanDroid (7/10/2012)


    Not certain why adding the server version would cause the answer to be any less clear.

    Because many of us prefer to answer based on current knowledge/guesswork, and then research it afterwards 🙂

  • Thanks for a really easy point! 😀

  • I nearly bit at the implication that SQL 2012 added syntax to allow truncating a table that met certain conditions. Had to find BOL 2012 online to disuade myself of that notion.

Viewing 15 posts - 16 through 30 (of 39 total)

You must be logged in to reply to this topic. Login to reply