Get maximum length for all fields all tables

Standard

Imagine a bunch of staging tables with all kinds of data and you want to create a new table for the data.

You want to get the maximum length of all the fields of alle tables. This is possible by the statement below.

The script only looks at text length and not data length. If you have an integer like ‘1234’ the script will return the number 4.
The script below will generate a statement for every table which can be copied of executed from a cursor.

The query will create a something like this:

maximumfield alltables

Leave a Reply