Cursor with dynamic sql

General covers Articles, Reference documentation, FAQs, Downloads and Blogs that do not belong to a specific subject area. General-purpose Articles about everything and anything
New Member

Cursor with dynamic sql

Hi i'm new to terradata. My requirement is to get distinct count of all columns of all tables in a database. For doing this I'm trying to write a cursor which will select all columns of a table from dbc.columns and pass one by one. Then we have to take distinct count of that column and insert in some temporary table. Can anyone plz share the full code.

Re: Cursor with dynamic sql

This will fill the requirement you mention,


SyntaxEditor Code Snippet

Sel columnname,count(*) from dbc.columnsv where databasename = 'YourDB' group by 1;