Unix Technical Forum

Very big table

This is a discussion on Very big table within the SQL Server forums, part of the Microsoft SQL Server category; --> Hi Expert, In my DB i have a big table like this: Primary key | param1 | para2 | ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-01-2008, 02:53 PM
Alex
 
Posts: n/a
Default Very big table

Hi Expert,
In my DB i have a big table like this:

Primary key | param1 | para2 | param3 | param4 | ... | param100|
------------------+-----------+---------+-----------+------------+----
+--------------+
| | | |
| | |

There is any way to build a parametric "Where" instead of manually
specification for example:

WHERE param1 = Y OR param2 = Y or param3 = Y ... param100 = Y

mybe for example:

WHERE paramx = Y

thanks

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-01-2008, 02:53 PM
DA Morgan
 
Posts: n/a
Default Re: Very big table

Alex wrote:
> Hi Expert,
> In my DB i have a big table like this:
>
> Primary key | param1 | para2 | param3 | param4 | ... | param100|
> ------------------+-----------+---------+-----------+------------+----
> +--------------+
> | | | |
> | | |
>


Then I would suggest you stop writing DML and fix the problem:

Primary Key | Parameter ID | Parameter Value

Your report writers, no doubt, will want to draw blood for such
an abominable lack of design.
--
Daniel A. Morgan
University of Washington
damorgan@x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-01-2008, 02:53 PM
Erland Sommarskog
 
Posts: n/a
Default Re: Very big table

Alex (ale.pam@gmail.com) writes:
> Hi Expert,
> In my DB i have a big table like this:
>
> Primary key | param1 | para2 | param3 | param4 | ... | param100|
> ------------------+-----------+---------+-----------+------------+----
> +--------------+
> | | | |
>| | |
>
> There is any way to build a parametric "Where" instead of manually
> specification for example:
>
> WHERE param1 = Y OR param2 = Y or param3 = Y ... param100 = Y
>
> mybe for example:
>
> WHERE paramx = Y



It is not unlikely that the best design for the table would have been:


CREATE TABLE details (primarykey ....,
paramno tinyint NOT NULL,
value ....,
CONSTRAINT pk_deatils(primarykey, paramno))

In this case the query would be trivial to write.

With the current design, you could generate the code, but in the end
you would need that long chain of ORs one way or another.

Relational databases are simply not meant to be used that way.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:40 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com