Hi,
We have a database with some tables with (what I would
denote as) 'referred field names'.
Like this:
DataTable1 with fields F1, F2, F3
DataTable2 with fields F3, F4, F5
DataTable3 with fields F1, F5, F2
We also have a table with field names
FieldNameTable with fields FIELD, NAME
containing data like:
FIELD NAME
----------------
F1 FieldName1
F2 FieldName2
F3 FieldName3
F4 FieldName4
F5 FieldName5
Now, we need a way to query the data of these tables, but
the result of the query should show the 'referred field names'
from the FieldNameTable.
For example, querying DataTable3 should produce the output
FieldName1 FieldName5 FieldName2
------------------------------------------
... ... ...
... ... ...
Any idea how (and whether) this can be done with an SQL query?
Thanks in advance for tips & tricks.
Dirk Vdm 6 1991
You would have to use dynamic SQL to do that - try and avoid it if you can.
Why not use a view to alias the column names instead of putting them in a
table?
--
David Portas
SQL Server MVP
--
"Dirk Van de moortel" <di**************@ThankS-NO-SperM.hotmail.com> wrote
in message news:y%********************@phobos.telenet-ops.be... Hi,
We have a database with some tables with (what I would denote as) 'referred field names'. Like this: DataTable1 with fields F1, F2, F3 DataTable2 with fields F3, F4, F5 DataTable3 with fields F1, F5, F2
We also have a table with field names FieldNameTable with fields FIELD, NAME containing data like: FIELD NAME ---------------- F1 FieldName1 F2 FieldName2 F3 FieldName3 F4 FieldName4 F5 FieldName5
Now, we need a way to query the data of these tables, but the result of the query should show the 'referred field names' from the FieldNameTable.
For example, querying DataTable3 should produce the output FieldName1 FieldName5 FieldName2 ------------------------------------------ ... ... ... ... ... ...
Any idea how (and whether) this can be done with an SQL query? Thanks in advance for tips & tricks.
Dirk Vdm
"David Portas" <RE****************************@acm.org> wrote in message news:lO********************@giganews.com... You would have to use dynamic SQL to do that - try and avoid it if you can. Why not use a view to alias the column names instead of putting them in a table?
-- David Portas SQL Server MVP --
Ah yes, of course. A few views will do the job just fine.
Thanks.
Dirk Vdm
Let's get back to the basics of an RDBMS. Rows are not records; fields
are not columns; tables are not files. Then you are mixing data and
metadata in complete violation of the basic princi-les of data
modeling.
What are you trying to do??? If you do not get a valid design, you
will wind up with dynamic SQL, procedural code, IDENTITY columns and
all kinds of other non-SQL nightmares.
"--CELKO--" <jc*******@earthlink.net> wrote in message news:11**********************@g43g2000cwa.googlegr oups.com... Let's get back to the basics of an RDBMS. Rows are not records; fields are not columns; tables are not files. Then you are mixing data and metadata in complete violation of the basic princi-les of data modeling.
I'm not mixing data and metadata. Someone else did. What are you trying to do???
Trying to make the best of someone else's mess without
interfering ;-)
If you do not get a valid design, you will wind up with dynamic SQL, procedural code, IDENTITY columns and all kinds of other non-SQL nightmares.
I know.
I will pass the message. In fact I alread have, but they
don't care.
Dirk Vdm
Sorry about that. Have you updated your resume yet? It is always best
to start looking before the company fails ...
"--CELKO--" <jc*******@earthlink.net> wrote in message news:11**********************@f14g2000cwb.googlegr oups.com... Sorry about that.
No problem.
Have you updated your resume yet? It is always best to start looking before the company fails ...
It's not the company I work for, and... I don't think it will
ultimately fail over this particular incovenience. If/when it fails,
we'll probably end up using another company's solution
(probably our own), and I'm sure it will have its own little
inconveniences ;-)
Cheers,
Dirk Vdm This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Earl Anderson |
last post by:
I have imported an Excel worksheet into A97/WinXPH which had the new
employees names in one field ( in a Last Name,First Name
configuration). I wanted to split that one field ( ) into two...
|
by: Tom |
last post by:
Data is collected over time in an Excel worksheet with 20 columns. The Excel
worksheet starts out as a copy of a template as is filled in as data is
collected. Eventually the worksheet file is...
|
by: Michael |
last post by:
Hi everyone,
I am trying to change the field names for a table that is being
exported via Excel. Its a spreadsheet that our National Office sends
us but even after promise after promise they...
|
by: Don Leverton |
last post by:
Hi Folks,
I have been given a CD with approx 130 .xls files (bean-counters!) that I
would like to import and merge to ONE table (tblTradeshow).
The XL files are *similarly*, but not...
|
by: HD |
last post by:
Hello. For the following, I would appreciate if anyone could tell me:
if it can be done, how it might done, and/or what search terms I could
use to find the solution myself.
I would like to...
|
by: Dixie |
last post by:
Can I set the Format property in a date/time field in code?
Can I set the Input Mask in a date/time field in code?
Can I set the Format of a Yes/No field to Checkbox in code?
I am working on...
|
by: sellcraig |
last post by:
Microsoft access
2 tables
table "data main" contains a field called "code"
table "ddw1" is created from a make table query of "data main"
Goal-
the data in "code" field in needs to...
|
by: Bob |
last post by:
Hi all,
I've got a table that I've imported and it has junk at the top of the
table, so after import I run a delete query to remove the junk lines
then I'm left with the field names I want for...
|
by: |
last post by:
Given an XML file (dataset.writexml), here is my output (simplified for this
posting):
<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<Category>
<CategoryId>80</CategoryId>...
|
by: justice750 |
last post by:
Hi All,
I am using a FormView control. The allows me to update records in the database. However, when a database field is null I can not update the field on the form. It works fine when the field...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |