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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
cleitoncabral2
Contributor III
Contributor III

Carregar tabelas e colunas SQL.

Boa tarde!


Alguém sabe como posso fazer para carregar todas as tabelas de um BD SQL para que possa saber todas as tabelas e colunas do banco??

Labels (1)
1 Solution

Accepted Solutions
Clever_Anjos
Support
Support

Se for SQL Server eu gosto de usar essa aqui:

select t.name as table_name

  ,SCHEMA_NAME(schema_id) as schema_name

  ,c.name as column_name

from sys.tables as t

inner join sys.columns c on t.OBJECT_ID = c.OBJECT_ID

where 1=1

order by schema_name

  ,table_name;

View solution in original post

8 Replies
Clever_Anjos
Support
Support

Qual banco?

SQL Server, Oracle, MySQL, etc?

Clever_Anjos
Support
Support

Se for SQL Server eu gosto de usar essa aqui:

select t.name as table_name

  ,SCHEMA_NAME(schema_id) as schema_name

  ,c.name as column_name

from sys.tables as t

inner join sys.columns c on t.OBJECT_ID = c.OBJECT_ID

where 1=1

order by schema_name

  ,table_name;

cleitoncabral2
Contributor III
Contributor III
Author

cleveranjos‌ eu colo isso no script e coloco a conexão??

É um SQL Server!

Clever_Anjos
Support
Support

Sim, isso irá trazer uma tabela com 3 colunas com os nomes das tabelas e colunas do seu banco.

Clever_Anjos
Support
Support

Você pode fazer isso interativamente também usando o "Selecionar"

248505.gif

cleitoncabral2
Contributor III
Contributor III
Author

Não entendi a parte de uma tabela com 3 colunas!!! hehehe

Clever_Anjos
Support
Support

Se você você tivesse testado aquele SQL que te passei (Assumindo que seja um SQL Server) ele irá trazer no seu Qlik uma tabela +- assim

Capturar.PNG

cleitoncabral2
Contributor III
Contributor III
Author

Entendi, eu vi lá deu certo, mas parece que algumas tabelas ele não trouxe... Mas já ajudou e muito!