Database Journal
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Tips Database Forum

» Database Journal Home
» Database Articles
» Database Tutorials
MS Access
SQL Scripts & Samples
» Database Forum
» Slideshows
Free Newsletters:

News Via RSS Feed

Database Journal |DBA Support |SQLCourse |SQLCourse2

Featured Database Articles


Posted Oct 11, 2000

Building Crosstabs from Access to SQL Server

By Alan Enderby

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

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


Note the transform procedure requires the previously posted batch_tsql

Have fun.
Download the batch utility

MS SQL Archives

Latest Forum Threads
MS SQL Forum
Topic By Replies Updated
SQL 2005: SSIS: Error using SQL Server credentials poverty 3 August 17th, 07:43 AM
Need help changing table contents nkawtg 1 August 17th, 03:02 AM
SQL Server Memory confifuration bhosalenarayan 2 August 14th, 05:33 AM
SQL Server Primary Key and a Unique Key katty.jonh 2 July 25th, 10:36 AM