我不知道是否有人可以提供帮助:
长话短说,我正在使用 MSSQL2005 构建数据透视表。正在检查的数据受日期范围限制(从最近的星期一到所选日期的 1 周内的所有数据)
当我运行存储过程并向其传递一个日期时,我会得到正确的表,例如:
时间< /strong> |
2009 年 1 月 1 日 |
2009 年 1 月 2 日 |
2009 年 1 月 3 日 |
... |
09:00 |
0 |
9 |
25 |
. .. |
09:30 |
8 |
27 |
65 |
... |
10:00 |
20 |
44 |
112 |
... |
我遇到的唯一问题是列标题会根据传递到 SP 的日期(所需的查看日期)和SP 内的逻辑(强制左侧列为距指定日期最近的星期一)。
这意味着当我向用户显示结果时,我(当前)需要复制经典 ASP 中的日期检查逻辑 [简单,但可维护性失败]
我真正需要的是一种从记录集本身检索列名的方法。
有人可以指出我正确的方向吗?
我已经用谷歌搜索过,但我得到的所有结果似乎都与读取表架构有关 - 这在这种情况下没有帮助,因为我的表是在内存中动态生成的。
非常感谢您可以提供的任何帮助
I wonder if someone can help:
Long story short, I'm using MSSQL2005 to build a Pivot table. The data being examined is limited by date range (All data for 1 week starting from the nearest Monday to the date selected)
When I run the Stored Proc and pass it a date, I get The correct table back eg:
Time |
1 Jan 09 |
2 Jan 09 |
3 Jan 09 |
... |
09:00 |
0 |
9 |
25 |
... |
09:30 |
8 |
27 |
65 |
... |
10:00 |
20 |
44 |
112 |
... |
The only problem I have is that the column headers will vary based on both the date passed in to the SP (The desired view date) and the logic inside the SP (which forces the left-hand column to be the nearest Monday to the date specified).
This means that when I display the results to the user, I (currently) need to duplicate the date-checking logic in classic ASP [easy but a maintainability fail]
What I really need is a way of retrieving the column names from the recordset itself.
Can someone please point me in the right direction?
I've Googled but all the results I get seem to relate to reading a Table Schema - which doesn't help in this case as my table is being generated on the fly in memory.
Many thanks in advance for any help you can provide
发布评论
评论(2)
给定一个 ado 记录集,您可以大致执行以下操作(这是伪代码):
这将为您提供字段的名称,请查看此 文档.
Given an ado record set you could do roughly the following (This is in psuedo code):
This will give you the name of the field check out this documentation.
像这样的事情应该做到这一点:-
Something like this ought to do it:-