I have a table created in sql. but in my application I am using the INFORMATION_SCHEMA to perform some tasks, I was surprised it wasn’t synchronized with my table definition, that is
Code:
SELECT SatComRatingTableID -- This is working
FROM dbo.tblSatComRatingTable
SELECT f.field ,
c.COLUMN_NAME
FROM dbo.wiztbl_Fields f
LEFT JOIN INFORMATION_SCHEMA.COLUMNS c ON c.COLUMN_NAME = f.Field
AND c.TABLE_NAME = 'tblSatComBillingPackage'
WHERE f.DataObjectID = 2717
AND COLUMN_NAME IS NULL
the second query returns:
SatComRatingTableID NULL
What is happening and how to fix it?
Thanks in advance
EDIT:
NB: the tblSatComBillingPackage contains a FK field SatComRatingTableID. I am using that field to get information from INFORMATION_SCHEMA…
You’re querying the wrong table, and seem to be filtering the results to preclude success: