home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.ms-sqlserver      Notorious Rube Goldberg contraption      19,505 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 17,907 of 19,505   
   Erland Sommarskog to Halgar   
   Re: How do I do this? (aka Can this be d   
   10 Sep 10 22:24:58   
   
   ef20708a   
   From: esquel@sommarskog.se   
      
   Halgar (tm_tech32@yahoo.com) writes:   
   > The problem is those column names sometimes need to change, Ampere   
   > Rating to Current Rating etc.  It has become tough to manage.   
   > Attributes columns come and go very often.   
   >   
   > I would like to manage all the attributes in a central table:   
   > Attribute_ID, Attribute_Label   
   > 101, Ampere Rating   
   >   
   > And changeover all the product tables to reference the ID as the   
   > column name.  I figure this way I can change the label in one place   
   > (as well as several other concepts suffix, prefix, alternate labels,   
   > etc.) and keep things consistent.   
   >   
   > THE QUESTION:   
   > When exporting tables to Excel or editing them directly in Enterprise   
   > Manager (or querying in Query Manager) I want to see the   
   > Attribute_Label as the column headers.  Outside of hard coding a view   
   > (and a static query) for each of the 300 tables, for each column to   
   > have an alias.... select attrib_001 as 'Ampere Rating', select   
   > attrib_002 as 'Voltage Rating', which defeats the purpose.   
      
   First: I think that using a numeric id is not a good idea, because   
   it is likely that you or someone else will sooner or later confuse   
   the numbers. Rather, I think it would be better to use mnemonic names,   
   maybe based on the current names.   
      
   The obvious solution would the be to define the tables from current   
   names, and don't change these names but keep them. Then you define   
   views from your mapping tables. These views would be generated from   
   this table. This could be done in a stored procedure, or it could be   
   done by a small program in the language of your choice: C#, VBscript,   
   Perl or whatever.   
      
   The drawback of using a stored procedure is that of the languages out   
   there, most languages have better support for string manipulation than   
   T-SQL has. Then again, a stored procedure could be started by a trigger   
   on the mapping table, making the process a little more automatic.   
      
   --   
   Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se   
      
   Links for SQL Server Books Online:   
   SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx   
   SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx   
   SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca