#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2008
    Posts
    6
    Rep Power
    0

    How to do stored procedure dynamically


    Hi

    I have an issue in below stored procedure.
    below Store procedure is working fine. But fixed the Year.
    Any one know How can do the year dynamically select by user?
    Pls advice

    Maideen

    Code:
    SELECT * FROM ( SELECT salesEXE,SalesEXEName,name,gross,YearNo FROM vw_Pivot_Month_ALL) TableYearNo
    pivot (Sum(gross) for [year] in ([2008],[2009],[2010],[2011],[2012],[2013],[2014],[2015],[2016],[2017],[2018],[2019],[2020])
    )pivotTable
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2014
    Posts
    3
    Rep Power
    0
    It's not very easy but you can check this link.
    Dynamic PIVOT in Sql Server | SqlHints.com

IMN logo majestic logo threadwatch logo seochat tools logo