I have a dynamic SQL query with different column names and tables at runtime.
I am looking to get the SQL query to ignore reading data based on if a row contains Null v
I am not sure what you mean by dynamic
, but if you mean that you actually build your queries at runtime, then you can get all available column names of all columns (that are nullable or not) for a given table in a given database, then you can simply put them together for your desired query.
SELECT
COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE
table_name = ''
AND IS_NULLABLE = 'YES'
AND TABLE_SCHEMA='';
(provided you already selected the correct database) (tables reference, columns reference)
SELECT
Cols.name
FROM sys.all_columns AS Cols
INNER JOIN sys.tables AS Tabs ON Cols.object_id = Tabs.object_id
WHERE
Tabs.name = ''
AND Cols.is_nullable = 1;
(having already selected the appropriate database)
SELECT
COLUMN_NAME
FROM ALL_TAB_COLUMNS
WHERE
TABLE_NAME = ''
AND NULLABLE = 'Y';
Not sure if this is a general Oracle-thing (as I am working mostly with SQL-Server), but when I tried this out with a fiddle, the table name I had to specify was always in uppercase letters.