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

» Database Journal Home
» Database Articles
» Database Tutorials
MS SQL
Oracle
DB2
MS Access
MySQL
» RESOURCES
Database Tools
SQL Scripts & Samples
Links
» Database Forum
» Sitemap
Free Newsletters:
DatabaseDaily  
News Via RSS Feed


follow us on Twitter
Database Journal |DBA Support |SQLCourse |SQLCourse2
 

Featured Database Articles

MS SQL

Posted Oct 10, 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
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



MS SQL Archives

Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 




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


















Thanks for your registration, follow us on our social networks to keep up-to-date