Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 30th, 2004, 04:07 AM
Ben Ben is offline
Authorized User
 
Join Date: Jun 2003
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL Help...

I have a table which contains three fields one a fk, one a category (Together they make a composite pk), and finally a value thats associated to the category. Each fk can have up to 9 category's with values, if a category has no value no entry would be made (Every fk will have at least 1 category).

Essientially I need to CrossTab this table, so I have the fk as a column with nine category columns filled with their values. I figured as we always want to report all nine categories and the number of categories is static, the most apt way of doing this would be a case statement with coalesce to treat the nulls, however I need to do this in an access data project which doesn't support the case statement :(

The quickest way I can think to do this now is through nine subqueries breaking the original table into nine new tables based on the categories - I figure this is quicker than doing 9 outer joins based on the original table and a Where Not Category = 1 or category = 2, etc. Can anyone confirm I'm going the right way?

I guess the other question I'd like to ask is if there would be a gain saving the subqueries as views and reference them, or specifying them all in one big query.
 
Old October 12th, 2004, 12:55 AM
Authorized User
 
Join Date: Apr 2004
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Can you use DECODE rather than CASE?

Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC
 
Old October 12th, 2004, 12:16 PM
sal sal is offline
Friend of Wrox
 
Join Date: Oct 2003
Posts: 702
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If this is a Access Data Project, you may get away with creating a pivot table form. The form will do the case for you.

Just make sure to index the tables properly or you will degrade server performance either way you do this.



Sal





Similar Threads
Thread Thread Starter Forum Replies Last Post
How Run .sql Script file in MS SQL Server 2000? aarkaycee SQL Server 2000 5 October 12th, 2009 05:43 AM
creating ssis packagte for sql server to sql serer Laxmikant_it ASP.NET 3.5 Professionals 0 November 26th, 2008 12:23 AM
Converting from MS SQL 2005 to Sql Epress edition saif44 SQL Language 0 February 16th, 2007 04:17 PM
Failed to copy objects from SQL server to SQL Serv monfu SQL Server 2000 4 December 4th, 2005 05:54 PM
Move SQL DB from one sql to another sql server Israr SQL Server 2000 3 January 24th, 2005 02:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.