Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Weird MS SQL "Error"

Weird MS SQL "Error"

Scheduled Pinned Locked Moved Database
csharpdatabasecomhelpquestion
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    GenJerDan
    wrote on last edited by
    #1

    I ran this in the Management Studio: update [Master] set Data_Thru = '7/23/2014 9:49:00 AM' where Data_Thru = '7/23/2014 8:00:00 AM' So why did it actually set the smalldatetime to 7/23/2014 9:50:00 AM? (And don't yell at me for the table name. It wasn't my idea.)

    We won't sit down. We won't shut up. We won't go quietly away. YouTube and My Mu[sic], Films and Windows Programs, etc.

    Richard DeemingR J B 3 Replies Last reply
    0
    • G GenJerDan

      I ran this in the Management Studio: update [Master] set Data_Thru = '7/23/2014 9:49:00 AM' where Data_Thru = '7/23/2014 8:00:00 AM' So why did it actually set the smalldatetime to 7/23/2014 9:50:00 AM? (And don't yell at me for the table name. It wasn't my idea.)

      We won't sit down. We won't shut up. We won't go quietly away. YouTube and My Mu[sic], Films and Windows Programs, etc.

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      Are you absolutely sure that that's the precise query that you executed, and that the row you're looking at is the one it updated? smalldatetime[^] will round to the nearest minute, but it will only round up if the seconds are greater than or equal to 29.999; anything else will round down.

      SELECT
      CAST('7/23/2014 9:49:29.998 AM' as smalldatetime),
      CAST('7/23/2014 9:49:29.999 AM' as smalldatetime)
      ;

      /*
      Output:
      2014-07-23 09:49:00
      2014-07-23 09:50:00
      */


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      G 1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        Are you absolutely sure that that's the precise query that you executed, and that the row you're looking at is the one it updated? smalldatetime[^] will round to the nearest minute, but it will only round up if the seconds are greater than or equal to 29.999; anything else will round down.

        SELECT
        CAST('7/23/2014 9:49:29.998 AM' as smalldatetime),
        CAST('7/23/2014 9:49:29.999 AM' as smalldatetime)
        ;

        /*
        Output:
        2014-07-23 09:49:00
        2014-07-23 09:50:00
        */


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        G Offline
        G Offline
        GenJerDan
        wrote on last edited by
        #3

        Richard Deeming wrote:

        Are you absolutely sure that that's the precise query that you executed, and that the row you're looking at is the one it updated?

        Yep. Freaked me out. I've never seen that before, and it had no problem with me going in and correcting it back down to 9:49 via T-Sql

        We won't sit down. We won't shut up. We won't go quietly away. YouTube and My Mu[sic], Films and Windows Programs, etc.

        Richard DeemingR 1 Reply Last reply
        0
        • G GenJerDan

          Richard Deeming wrote:

          Are you absolutely sure that that's the precise query that you executed, and that the row you're looking at is the one it updated?

          Yep. Freaked me out. I've never seen that before, and it had no problem with me going in and correcting it back down to 9:49 via T-Sql

          We won't sit down. We won't shut up. We won't go quietly away. YouTube and My Mu[sic], Films and Windows Programs, etc.

          Richard DeemingR Offline
          Richard DeemingR Offline
          Richard Deeming
          wrote on last edited by
          #4

          Weird. Are there any triggers on that table? Or other users updating the same row at the same time? :confused:


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

          G 1 Reply Last reply
          0
          • Richard DeemingR Richard Deeming

            Weird. Are there any triggers on that table? Or other users updating the same row at the same time? :confused:


            "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

            G Offline
            G Offline
            GenJerDan
            wrote on last edited by
            #5

            Nope. No triggers. And no users at all (yet). Maybe we'll have to pass it off as a cosmic ray hitting the server and flipping a bit at just the right time. I see no resason for it, and Google came up with nothing, either.

            We won't sit down. We won't shut up. We won't go quietly away. YouTube and My Mu[sic], Films and Windows Programs, etc.

            1 Reply Last reply
            0
            • G GenJerDan

              I ran this in the Management Studio: update [Master] set Data_Thru = '7/23/2014 9:49:00 AM' where Data_Thru = '7/23/2014 8:00:00 AM' So why did it actually set the smalldatetime to 7/23/2014 9:50:00 AM? (And don't yell at me for the table name. It wasn't my idea.)

              We won't sit down. We won't shut up. We won't go quietly away. YouTube and My Mu[sic], Films and Windows Programs, etc.

              J Offline
              J Offline
              jschell
              wrote on last edited by
              #6

              When I run into impossible situations in code then the only solution is to examine my assumptions. That is always where I find the problem that lead to the impossibility in the first place.

              1 Reply Last reply
              0
              • G GenJerDan

                I ran this in the Management Studio: update [Master] set Data_Thru = '7/23/2014 9:49:00 AM' where Data_Thru = '7/23/2014 8:00:00 AM' So why did it actually set the smalldatetime to 7/23/2014 9:50:00 AM? (And don't yell at me for the table name. It wasn't my idea.)

                We won't sit down. We won't shut up. We won't go quietly away. YouTube and My Mu[sic], Films and Windows Programs, etc.

                B Offline
                B Offline
                Bernhard Hiller
                wrote on last edited by
                #7

                What's the version / localization of your SQL Server? I tried it with SQL Server 10.0.5500, German localized Management studio. I adjusted the date format of your query, and tested it. And it worked as it was expected to work - I cannot reproduce your bug.

                G 1 Reply Last reply
                0
                • B Bernhard Hiller

                  What's the version / localization of your SQL Server? I tried it with SQL Server 10.0.5500, German localized Management studio. I adjusted the date format of your query, and tested it. And it worked as it was expected to work - I cannot reproduce your bug.

                  G Offline
                  G Offline
                  GenJerDan
                  wrote on last edited by
                  #8

                  10.50.1617.0 Management studio hitting 2008 R2 10.0.5500.0 I think it was a one-time glitch. I hate those.

                  We won't sit down. We won't shut up. We won't go quietly away. YouTube and My Mu[sic], Films and Windows Programs, etc.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups