You can only run one DDL statement in a macro, so you cannot do this by macro.
Also, you do not need to collect the columnnames if you just want a Select * view.
If you run the following BTEQ script, it will set up a view in a viewsdb for every table in a data database:
------------------------------------------------------------------------
.Export Report File = CViews.sql
.Rtitle ''
.Foldline on
.Format Off
Select 'Replace View ViewsDb.V'||Tablename (Title '')
, 'As Select * From DataDB.'||Tablename (Title '')
, ';' (Title '')
From DBC.Tables
Where Databasename = 'DataDb'
Order By Tablename
;
.Export Reset
.Run File CViews.sql
-----------------------------------------------------
You will need to change the data and views databasenames in the script.
If you need the columnnames for some reason you can get them for DBC.Columns but you need to use Case to only get the Create and Select components on the first and last columns. Come back if you need that and cannot work it out.
Hi all!
I am trying to build around 300 views. The views are just a (Sel * from table) , but getting the column names from each table is pretty cumbersome. IS there a macro which will collect the column names for all teh tables and create DDL's for teh views?
Thank you!