I have a query that should be ignoring my applications system columns, I can't explain why it's not detecting the following column as a system column. A system column starts with DW_ and could contain a space, hence the use of quotename.
DECLARE @columnName NVARCHAR(max)
set @columnName = Quotename('DW_ID')
print @columnName
IF (@columnName LIKE 'DW_%')
print 'system column'
else
print 'non system column'
I would expect the above query to tell me it's a system column but it tells me it's a non system column.