Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

Extractin a QUERY TEXT from a Column and using this output we need to insert the data into another table. - response (5) by Raja_KT

$
0
0

I hope you understand this logic 1:

 select 'insert into '||trim(databasename)||''||trim(tablename) from dbc.tables where tablename='raja_test' and databasename='xxxx'; ---It gets you the statement

insert into yourdbname.yourtablenam  Note :You can use IN  instead of = sign

 

 

Since I can see you have only around 50 rows, you can use excel against your queries and then paste the whole code into a bteq and run.

I tried for one row and it works as below:

 

select 'insert into  '||trim(t.databasename)||'.'||trim(t.tablename)||a.id from dbc.tables  t,xxxx.raja_test a where t.tablename='raja_test' and t.databasename='xxxx'

and t.tablename=a.tablename

 

ct xxxx.raja_test(id varchar(5000),tablename varchar(30));

insert into xxxx.raja_test('select (*) from abc','raja_test');

 

Hope you will try at least :).

 

 

Cheers,

 

Raja


Viewing all articles
Browse latest Browse all 14773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>