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,909 of 19,505   
   Erland Sommarskog to Halgar   
   Re: How do I do this? (aka Can this be d   
   13 Sep 10 22:19:40   
   
   dce6e6a6   
   From: esquel@sommarskog.se   
      
   Halgar (tm_tech32@yahoo.com) writes:   
   > I guess that is more specifically what I am asking for help with.  The   
   > only way I can see to create a view, where a column name uses an   
   > alias, is to hard code the text alias in the view creation.   
      
   Yes, that is how the final views would look like. But my point is that you   
   would generate the views.   
      
   > How would I pull the alias value (or am I looking for an alternative   
   > method) from another table?   
      
   Like you would read any table:   
      
      SELECT alias_name, table_coumn, table_name   
      FROM   mapping_table   
      ORDER  BY table_name   
      
   Then start a new CREATE VIEW statement each time you get a new table name.   
   And execute the one you have just completed.   
      
   > That would seem to be the logic but I can't get it to work, I have   
   > tried unsuccessfully to wrap it in an EXEC line.   
      
   But why use T-SQL? T-SQL is definitely not the best choice for this task.   
   Sure you can do it. Put the above in a cursor and build the strings. But   
   there are legions of languages out there that are better fitted to build   
   strings in.   
      
      
   --   
   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