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 in SQL

Stored procedures in SQL

Scheduled Pinned Locked Moved Database
databasesysadminperformancequestion
3 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    What are the best practices for writing stored procedures in SQL which improves the performance of the server?:)

    R K 2 Replies Last reply
    0
    • L Lost User

      What are the best practices for writing stored procedures in SQL which improves the performance of the server?:)

      R Offline
      R Offline
      Ricardo Casquete
      wrote on last edited by
      #2

      Try to restrict the queries result set by using the WHERE clause. Try to restrict the queries result set by returning only the particular columns from the table, not all table's columns. Use views and stored procedures instead of heavy-duty queries. Try to avoid using SQL Server cursors, whenever possible. If you need to return the total table's row count, you can use alternative way instead of SELECT COUNT(*) statement. Try to use constraints instead of triggers, whenever possible. Use table variables instead of temporary tables. Try to avoid the HAVING clause, whenever possible. Try to avoid using the DISTINCT clause, whenever possible. Include SET NOCOUNT ON statement into your stored procedures to stop the message Use the select statements with TOP keyword or the SET ROWCOUNT statement, if you need to return only the first n rows. Use the FAST number_rows table hint if you need to quickly return 'number_rows' rows. UNION ALL statement instead of UNION, whenever possible. Ricardo Casquete

      1 Reply Last reply
      0
      • L Lost User

        What are the best practices for writing stored procedures in SQL which improves the performance of the server?:)

        K Offline
        K Offline
        Kodanda Pani
        wrote on last edited by
        #3

        Hi Deeksha, Guess the following links will help you. http://vyaskn.tripod.com/coding\_conventions.htm http://www.extremeexperts.com/SQL/Articles/BestPractices.aspx Thanks and Regards Pani

        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