I have recently made a big change to the database and moved bunch of columns into a new schema table.
So say, [myschema].[dbo].[TableA]
used to have a column called isTestData
, but I've made a change to the database so that the column now exists in [Main].[dbo].[TableA]
(table name is the same, but schema is different).
The problem that I am facing is that there are some stored procedures which reference isTestData
from the old table ([myschema].[dbo].[TableA]
). So I re-compiled every stored procedure that I have in the system so that I could get a list of stored procedures with compilation errors.
However, after running sp_recompile
, I found out that there are no compilation errors being returned even though when I open up that specific stored procedure, it's got a red line in SSMS. It's compiles fine but errors out when you execute it which is expected as that column is now missing from the old table.
Is there a way to get a compilation error if column is missing?
USE [myschema]
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
...
SELECT a, b, c
FROM TableA
WHERE isTestData = 0
This is the summarised stored procedure that is failing.
Thanks everyone.