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. stored procedures - avoiding recompilations [modified]

stored procedures - avoiding recompilations [modified]

Scheduled Pinned Locked Moved Database
databasesql-serversysadminhelptutorial
5 Posts 3 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.
  • M Offline
    M Offline
    Marek Grzenkowicz
    wrote on last edited by
    #1

    I am working on optimizing an application that uses stored procedures heavily. Almost every procedure starts with:

    SET DATEFORMAT dmy

    which causes a recompilation during the procedure execution. It takes about 5 seconds. Is there any way to set the dmy as a default setting on the startup of the application? Any other ideas how to solve this problem? I use MS SQL Server 2000.

    modified on Monday, August 30, 2010 6:32 AM

    C M 2 Replies Last reply
    0
    • M Marek Grzenkowicz

      I am working on optimizing an application that uses stored procedures heavily. Almost every procedure starts with:

      SET DATEFORMAT dmy

      which causes a recompilation during the procedure execution. It takes about 5 seconds. Is there any way to set the dmy as a default setting on the startup of the application? Any other ideas how to solve this problem? I use MS SQL Server 2000.

      modified on Monday, August 30, 2010 6:32 AM

      C Offline
      C Offline
      Chris Meech
      wrote on last edited by
      #2

      I know Oracle has a default date format that is set as part of the database configuration. I would suspect the same is true for SQL Server, but I'm not up on it. Either I try to avoid depending upon defaults when writing a stored procedure. In the long run, you will have less headaches if within your procedure, you translate between the strings and date types using explicit formats. For example;

      convert a date to a string
      to_char(some_date_field,'dmy')

      convert a string to a date
      to_date(some_char_field,'dmy')

      Chris Meech It's much easier to get rich telling people what they want to hear. Christopher Duncan I can't help getting older, but I refuse to grow up. Roger Wright I've been meaning to change my sig. Thanks! Alvaro Mendez We're more like a hobbiest in a Home Depot drooling at all the shiny power tools, rather than a craftsman that makes the chair to an exacting level of comfort by measuring the customer's butt. Marc Clifton

      M 1 Reply Last reply
      0
      • M Marek Grzenkowicz

        I am working on optimizing an application that uses stored procedures heavily. Almost every procedure starts with:

        SET DATEFORMAT dmy

        which causes a recompilation during the procedure execution. It takes about 5 seconds. Is there any way to set the dmy as a default setting on the startup of the application? Any other ideas how to solve this problem? I use MS SQL Server 2000.

        modified on Monday, August 30, 2010 6:32 AM

        M Offline
        M Offline
        Mike Dimmick
        wrote on last edited by
        #3

        I'd recommend using invariant date formats throughout: yyyymmdd. You could also set the default language database option - see this article in Books Online[^] for more details.

        M 1 Reply Last reply
        0
        • C Chris Meech

          I know Oracle has a default date format that is set as part of the database configuration. I would suspect the same is true for SQL Server, but I'm not up on it. Either I try to avoid depending upon defaults when writing a stored procedure. In the long run, you will have less headaches if within your procedure, you translate between the strings and date types using explicit formats. For example;

          convert a date to a string
          to_char(some_date_field,'dmy')

          convert a string to a date
          to_date(some_char_field,'dmy')

          Chris Meech It's much easier to get rich telling people what they want to hear. Christopher Duncan I can't help getting older, but I refuse to grow up. Roger Wright I've been meaning to change my sig. Thanks! Alvaro Mendez We're more like a hobbiest in a Home Depot drooling at all the shiny power tools, rather than a craftsman that makes the chair to an exacting level of comfort by measuring the customer's butt. Marc Clifton

          M Offline
          M Offline
          Marek Grzenkowicz
          wrote on last edited by
          #4

          Chris Meech wrote: In the long run, you will have less headaches if within your procedure, you translate between the strings and date types using explicit formats I thought about it. However, the problem is that my task is to optimize a system that uses many stored procedures written by different people. I would have to go through all the procedures (I haven't written any of them!) and find places where using converting functions is necessary. Sounds like a nightmare to me. :)

          modified on Monday, August 30, 2010 6:32 AM

          1 Reply Last reply
          0
          • M Mike Dimmick

            I'd recommend using invariant date formats throughout: yyyymmdd. You could also set the default language database option - see this article in Books Online[^] for more details.

            M Offline
            M Offline
            Marek Grzenkowicz
            wrote on last edited by
            #5

            Mike Dimmick wrote: You could also set the default language database option Great idea! I did not know it sets not only the language but also the date format. Thanks.

            modified on Monday, August 30, 2010 6:33 AM

            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