Building Crosstabs from Access to SQL Server | Database Journal

Building Crosstabs from Access to SQL Server

Written By
Alan Enderby
Alan Enderby
Oct 11, 2000
1 minute read

I had to do a Cross Tab today.

I had the code in MS/ACCESS as a
TRANSFORM statement and set about
creating a procedure to emulate it in
SQL/Server.

The main aim was to recreate the report that I had produced
in ACCESS
and it does.

It should also do everything else that you
would expect of the
TRANSFORM statement and more.
It is in a very
embryonic state at the moment and will probably
undergo several
facelifts.
There is no error checking so use the @debug option to see what is

going on behind the scenes.

I’d like to share the code for comments
and suggestions for
improvements.

As with all my code the comments
are sparse and badly spelt.

Most of my procedures and tables live in a
database called common. I
prefer to place code in this database rather than
master.
Partly because I can copy the common database from server to
server.

Anyway here goes

transform_table.SQL
transform_xample.SQL
transform3.SQL

Note the transform procedure requires the previously posted
batch_tsql
procedure

Have fun.

Download the batch utility

Database Journal Logo

DatabaseJournal.com publishes relevant, up-to-date and pragmatic articles on the use of database hardware and management tools and serves as a forum for professional knowledge about proprietary, open source and cloud-based databases--foundational technology for all IT systems. We publish insightful articles about new products, best practices and trends; readers help each other out on various database questions and problems. Database management systems (DBMS) and database security processes are also key areas of focus at DatabaseJournal.com.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.