SQL Server variable columns name?

前端 未结 4 1967
刺人心
刺人心 2020-11-29 10:59

I am wondering why I cannot use variable column name like that:

declare @a as varchar;
set @a=\'TEST\'

select @a from x;

Thank you

4条回答
  •  悲&欢浪女
    2020-11-29 11:36

    Because the column names are resolved at compile time not at run time for the SQL statement.

提交回复
热议问题