Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Mastering Change Data Capture: Read Now
cancel
Showing results for 
Search instead for 
Did you mean: 
nivedhitha
Creator III
Creator III

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

 

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable

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

1 Reply
Anonymous
Not applicable

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