Get the schema of tables and load it to a table

Highlighted
Eight Stars

Get the schema of tables and load it to a table

Hi everyone,

 

I have a situation where I have to get a set of tables from SQL Server and get the schema(columns, datatypes, schema etc) details of all the tables and load these into a table.

Any suggestions/ idea?

Thanks in advance

 


Accepted Solutions
Six Stars

Re: Get the schema of tables and load it to a table

you can use tMSSqlInput to execute below SQL. It will give you the complete list of schema. you can dump it to a file and load it to the target.

 

select COLUMN_NAME, DATA_TYPE,IS_NULLABLE,
       CASE WHEN CHARACTER_MAXIMUM_LENGTH IS NOT NULL THEN CONVERT(VARCHAR,CHARACTER_MAXIMUM_LENGTH)
          WHEN NUMERIC_PRECISION is not NULL then
              CASE WHEN NUMERIC_SCALE IS NOT NULL THEN '('+ CONVERT(VARCHAR,NUMERIC_PRECISION)+','+CONVERT(VARCHAR,NUMERIC_SCALE)+')'
               ELSE '('+ CONVERT(VARCHAR,NUMERIC_PRECISION)+', 0)'
                END
       END as LENGTH
from INFORMATION_SCHEMA.COLUMNS
where  TABLE_SCHEMA='<yourSchema>';

 

 

Hope this helps.

 

Regards,

Ragu

View solution in original post


All Replies
Six Stars

Re: Get the schema of tables and load it to a table

you can use tMSSqlInput to execute below SQL. It will give you the complete list of schema. you can dump it to a file and load it to the target.

 

select COLUMN_NAME, DATA_TYPE,IS_NULLABLE,
       CASE WHEN CHARACTER_MAXIMUM_LENGTH IS NOT NULL THEN CONVERT(VARCHAR,CHARACTER_MAXIMUM_LENGTH)
          WHEN NUMERIC_PRECISION is not NULL then
              CASE WHEN NUMERIC_SCALE IS NOT NULL THEN '('+ CONVERT(VARCHAR,NUMERIC_PRECISION)+','+CONVERT(VARCHAR,NUMERIC_SCALE)+')'
               ELSE '('+ CONVERT(VARCHAR,NUMERIC_PRECISION)+', 0)'
                END
       END as LENGTH
from INFORMATION_SCHEMA.COLUMNS
where  TABLE_SCHEMA='<yourSchema>';

 

 

Hope this helps.

 

Regards,

Ragu

View solution in original post

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog