Re: Array Statements in SQL, Using Column Name Wildcards...
From: Louis Davidson (dr_dontspamme_sql_at_hotmail.com)
Date: 08/05/04
- Next message: Louis Davidson: "Re: stored procedures & cursors"
- Previous message: Homer J. Simpson: "Query for specific bits?"
- In reply to: AJ: "Array Statements in SQL, Using Column Name Wildcards..."
- Next in thread: G.C.Mandrake: "Re: Array Statements in SQL, Using Column Name Wildcards..."
- Reply: G.C.Mandrake: "Re: Array Statements in SQL, Using Column Name Wildcards..."
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 5 Aug 2004 16:03:25 -0500
Since it is a violation of most of the rules of proper database design to
have columns named N1, N2, N3,...,N50 it is not something that is built into
SQL. However, a table like:
N
--------------
table_name_id (foreign key to the table_name table)
n_id (whatever key, in your case probably an integer from 1 to 50)
value (storing the value from N)
Is supported quite easily and is in more relational format. You can then
pivot the rows for display using some SQL tricks, or better yet the user
interface. It can be a bit of a challenge to wrap your head around, but it
does make life much easier.
-- ---------------------------------------------------------------------------- Louis Davidson (drsql@hotmail.com) Compass Technology Management Pro SQL Server 2000 Database Design http://www.apress.com/book/bookDisplay.html?bID=266 Note: Please reply to the newsgroups only unless you are interested in consulting services. All other replies will be ignored :) "AJ" <AJ@discussions.microsoft.com> wrote in message news:4CD17BE0-3D86-4CE2-94A7-CB8CA13560B7@microsoft.com... > I'm new to SQL programming. Are there column name wildcards in SQL? If I have a table with columns labelled N1, N2, N3,...,N50 (plus other fields) is there an easy way to Select, or Sum etc without typing out each of the column names? SAS for example allows you define and do operations on arrays. > > What if I want to Select columns N7 through N50? I know I can say: > > Select N7, N8, N9,..., N50 from table_name > > But is there an easier way to reference tables with similar names? > > Thanks, > AJ > >
- Next message: Louis Davidson: "Re: stored procedures & cursors"
- Previous message: Homer J. Simpson: "Query for specific bits?"
- In reply to: AJ: "Array Statements in SQL, Using Column Name Wildcards..."
- Next in thread: G.C.Mandrake: "Re: Array Statements in SQL, Using Column Name Wildcards..."
- Reply: G.C.Mandrake: "Re: Array Statements in SQL, Using Column Name Wildcards..."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|