SQL Views - no variables?

前端 未结 8 1890
北荒
北荒 2020-12-04 17:31

Is it possible to declare a variable within a View? For example:

Declare @SomeVar varchar(8) = \'something\'

gives me the syntax error:

8条回答
  •  庸人自扰
    2020-12-04 17:48

    Yes this is correct, you can't have variables in views (there are other restrictions too).

    Views can be used for cases where the result can be replaced with a select statement.

提交回复
热议问题