Skip to content

Instantly share code, notes, and snippets.

View allansli's full-sized avatar

allansli.eth allansli

View GitHub Profile
SELECT '<TABELAS>' +
(SELECT
TABELA.NAME AS 'NOME'
, COLUNA.NAME AS 'NOME'
, CASE WHEN COLUNA.PRECISION > 0 THEN COLUNA.PRECISION ELSE COLUNA.MAX_LENGTH END AS 'TAMANHO'
, COLUNA.scale AS 'ESCALA'
, CASE COLUNA.IS_NULLABLE WHEN 1 THEN 'N' ELSE 'S' END AS 'OBRIGATORIO'
, CASE WHEN (SELECT COUNT(*)
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS C
JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS K
DECLARE @QUERY_SELECT VARCHAR(MAX);
DECLARE @NOME_TABELA VARCHAR(MAX);
DECLARE @NOME_COLUNA VARCHAR(MAX);
DECLARE @VALOR_COLUNA VARCHAR(MAX);
DECLARE @QUERY_WHERE VARCHAR(MAX);
DECLARE @COLUNA_CHAVE VARCHAR(1);
DECLARE @COLUNA_EDITAVEL VARCHAR(1);
DECLARE @TIPO_COLUNA VARCHAR(MAX);
DECLARE @TEM_FILTRO BIT;
DECLARE @VALOR_NUMERICO VARCHAR(MAX);