You are here: Re: SQL for field names from a table « MsSQL Server « IT news, forums, messages
Re: SQL for field names from a table

Posted by David Portas on 10/07/05 00:39

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" <dirkvandemoortel@ThankS-NO-SperM.hotmail.com> wrote
in message news:y%e1f.14958$RR3.656506@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
>
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация