What I am trying to do here is create a dynamic query where DBAs only have to change the column name at the variable level, the reason of this is because we have multiple DBs that were horrendously created and even though they have the same data, the column names change from one to another (there is no normalization between them).
I am working on a query where it has around 400 lines and what I am trying to avoid is pass the logic to another DBA where they have to go through the script and replace all the column names... but instead just assign the column name that match from their DB to the logic. Not sure if this could be possible.
This is an example:
Declare @ColumnA
Declare @ColumnB
set @ColumnA = 'UserID'
set @ColumnB = 'Salary'
select @ColumnA,@ColumnB from Table
How can I achieve this kind of functionality?
int
variable. :D – InterflowDeclare @ColumnA int = 'UserID'
and tell me if you are lucky. ;) – Interflow