• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 208
  • Last Modified:

Pivot Table

Can I use the SQL from Access below exactly the same in a stored Proc?  I do not have access to test in SQL Server right now.

TRANSFORM Count(AllStat.Position) AS CountOfPosition
SELECT AllStat.[Position Status]
FROM AllStat
GROUP BY AllStat.[Position Status]
PIVOT AllStat.Age;
0
LiCann
Asked:
LiCann
  • 2
1 Solution
 
dqmqCommented:
>Can I use the SQL from Access below exactly the same in a stored Proc?

No, that syntax is not valid in TSQL

0
 
dqmqCommented:
Furthermore, TSQL does not have anything equivalent to the PIVOT clause, which determines column headings from a data column.  TSQL has a PIVOT statment, but it requires hardcoded column headings.   However, you can emulate the TRANSFORM functionality by using dynamic SQL to construct a SELECT statement with a PIVOT clause.

If you search for "dynamic pivot" in this forum you will find examples.




0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now