I need to pass Column name as [ID-ColumnName] as column name in order by for a table.
Ex:
Select [ID-ColumnName],[ID2-ColumnName2] FROM TABLE1 ORDER BY [ID-ColumnName]
Problem is if the ColumnName which is dynamic name comes with one opening/closing square brackets e.g Column[Name or Column]Name
In this scenario the SQL statement is breaking; Problem is I dont know how many such open/close square brackets can come.
Wrapping the column name with square brackets is mandatory in my scenario.
Please help me handling this scenario.