Here is my code:
CREATE TABLE [dbo].[TestTable](
ColumnA VARCHAR(20),
ColumnB VARCHAR(20))
INSERT INTO TestTable
SELECT 'TestA', 'TestB'
IF COL_LENGTH('TestTable', 'ColumnC') IS NOT NULL
BEGIN
PRINT 'ColumnC Present'
SELECT ColumnC FROM TestTable
END
As you can see it should only query ColumnC if it is actually present. However the mgmt studio blocks the execution of the whole query. Basically what I want is to query for the value of ColumnC if this column exists. I am writing a query for a software on multiple versions, some versions have this column older versions do not.