Cross Tab - Storing different dates (Meeting1, Meeting2, Meeting 3 etc) in the same column

后端 未结 4 2084
夕颜
夕颜 2021-01-06 10:49

I need to keep track of different dates (dynamic). So for a specific Task you could have X number of dates to track (for example DDR1 meeting date, DDR2 meeting date, Due Da

4条回答
  •  -上瘾入骨i
    2021-01-06 11:25

    If the pivoted columns are unknown (dynamic), then you'll have to build up your query manually in either ms-sql 2000 or 2005, ie with out without PIVOT.

    This involves either executing dynamic sql in a stored procedure (generally a no-no) or querying a view with dynamic sql. The latter is the approach I generally go with.

    For pivoting, I prefer the Rozenshtein method over case statements, as explained here:

    http://www.stephenforte.net/PermaLink.aspx?guid=2b0532fc-4318-4ac0-a405-15d6d813eeb8

    EDIT

    You can also do this in linq-to-sql, but it emits some pretty inefficient code (at least when I view it through linqpad), so I don't recommend it. If you're still curious I can post an example of how to do it.

提交回复
热议问题