Site sponsored by: Idera Try Idera’s new SQL admin toolset
SQL Server Performance

  • Home
  • Articles
  • Forums
  • Tips
  • Quiz
  • FAQ's
  • Blogs
  • Software
  • Books
  • About Us
RSS Feeds
Sign in | Join


Article Topics

All Articles
Performance Tuning
Audit
Business Intelligence
Clustering
Reporting Services
Developer
General DBA
ASP.NET / ADO.NET

Write for Us

Share you SQL Server knowledge with others and raise your profile in the community More...
Latest Articles

Compare Dates
Filtered Indexes in SQL Server 2008
Importance of Database Backups and Recovery Plan
Data Compression in SQL Server 2008

More     
 
Latest FAQ's

ALTER TABLE SWITCH statement failed because the object '%.*ls' is not ...
ALTER TABLE SWITCH statement failed because column '%.*ls' at ordinal %d ...
ALTER TABLE SWITCH statement failed because table '%.*ls' has %d columns ...
SQL Server Reporting Server (SSRS) service is failing to start ...

More     
   
Latest Software Reviews

Spotlight on ApexSQL Doc 2008
ApexSQL Enforce
Embarcadero Change Manager
SQL Server DBA Dashboard

More     

articles >> developer >> SQL Server Techniques for Creating a Web ...

SQL Server Techniques for Creating a Web Reporting Page -- Part 2

By : Louis Duc Nguyen
Jun 22, 2003

Page 3 / 3

HOW IT WORKS

We alter the parameter @method’s default to “groupSalesWithTotal”. We also add the @type parameter. Within the existing “groupSales” code block, we add an insert statement and add another output column. “insert into #R (type,region,empid,sumSales) select type=@type…”  Instead of returning the result set, SQL will now insert it into the temp table #R and add a new column TYPE. Where is the temp table #R created?  The temp table is created in the main method. For example, suppose you are using Query Analyzer. You create a temp table. You perform an insert. You perform another insert. You perform a “select * from …”. SQL returns the 2 rows that you inserted. During this whole exercise, you are within the same session – meaning the temp table is available to the different statements. If we execute the main method and it executes the drone, we are within the same session – meaning the temp table created by the main method is available to the drone. The “groupSalesWithTotal” method code block: creates the temp table #R, calls upon “groupSales”, calls upon “groupSales” again for the total row, and returns the contents of #R.

EXAMPLE OUTPUT:

exec cubesp @group='region'

TYPE REGION EMPID sumSales       

Body East 0 4

Body North 0 24

Body South 0 46

Body West 0 64

Total  0 138

This concludes our article about SORT & TOTAL ROWS. I plan to write one more article demonstrating PIVOT/TRANSPOSE functionality.

 

About the Author

Louis Duc Nguyen lives in Dallas, TX and has a BS in Engineering and an MBA from University of Texas at Austin and Dallas. He is currently working for a major airline. He specializes in creating data-entry and reporting applications. Please address comments and hot job tips to Louis Nguyen at louisducnguyen@hotmail.com.

 

Copyright © 2002-2003 Louis Duc Nguyen All Rights Reserved


<< Prev Page         








Home | Peformance Articles | Audit Articles | Business Intelligence Articles | Clustering Articles | Developer Articles | Reporting Services Articles | DBA Articles | ASP.NET / ADO.NET Articles | DBA FAQ's | Developer Peformance FAQ's | DBA Peformance FAQ's | Developer FAQ's | Clustering FAQ's | Error Messages | Audit Tool Reviews | Backup Tool Reviews | Coding Tool Reviews | Compare Tool Reviews | Documentation Tool Reviews | Design Tool Reviews | Monitoring Tool Reviews | Log Tool Reviews | Reporting Tool Reviews | Clustering Tool Reviews | Security Tool Reviews | Change Management Tool Reviews | Remote Access Tool Reviews | Book Reviews | Security Tool Reviews | QDPMA Performance Tuning | ADO.NET / ASP.NET | Administration | Analysis/OLAP Services | Application Development | Configuration | Components | ETL | Hardware | High Availability | Hints | Index | Misc | Operating Systems | Performance Tuning | Replication | T-SQL | Views


              © 1999-2008 by T10 Media. All rights reserved