【问题标题】:SQL Server 2008 / 2012 - views & sql formattingSQL Server 2008 / 2012 - 视图和 sql 格式
【发布时间】:2015-11-09 08:39:36
【问题描述】:

希望这是一个新手问题。

因此,如果我的 SQL 中有很长的一组选择,而 where 子句中有几个子选择,我对视图设计器中的格式不太满意,这似乎是唯一的方法在保存后显示/显示我的视图。

那么,简而言之,有什么方法可以直接在 SSMS 中编辑我的视图,并让视图保留我代码中的格式?

即;

select case /*comment */
  when a = 5  
   then b = 2 
   else b = 4  /* why b 4 */
  end as field_1,
  dt as field_2,...

全部搞定

select case /*comment */     when a = 5                  
then b = 2                 else b = 4  /* why b 4 */              
end as field_1,             
dt as field_2,...

或者类似的东西。

【问题讨论】:

标签: sql sql-server coding-style code-formatting query-designer


【解决方案1】:

您在使用查询设计器吗?而是使用 SSMS 查询窗口。在 SSMS 对象资源管理器中,右键单击视图并选择 Script View as-->Alter To-->New Query Editor 窗口。在查询窗口中格式化视图源并运行脚本以更改视图。您的格式将被保留。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-20
    • 1970-01-01
    相关资源
    最近更新 更多