sql-server – 如何清除SSMS中的空行?

前端之家收集整理的这篇文章主要介绍了sql-server – 如何清除SSMS中的空行?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有很多.sql文件有很多空行,例如
WITH

  cteTotalSales (SalesPersonID,NetSales)

  AS

  (

    SELECT SalesPersonID,ROUND(SUM(SubTotal),2)

    FROM Sales.SalesOrderHeader

    WHERE SalesPersonID IS NOT NULL

    GROUP BY SalesPersonID

  )

SELECT

  sp.FirstName + ' ' + sp.LastName AS FullName,sp.City + ',' + StateProvinceName AS Location,ts.NetSales

FROM Sales.vSalesPerson AS sp

  INNER JOIN cteTotalSales AS ts

    ON sp.BusinessEntityID = ts.SalesPersonID

ORDER BY ts.NetSales DESC

有没有办法在sql Server Management Studio删除这些空行?这是我想要的:

WITH
  cteTotalSales (SalesPersonID,NetSales)
  AS
  (
    SELECT SalesPersonID,2)
    FROM Sales.SalesOrderHeader
    WHERE SalesPersonID IS NOT NULL
    GROUP BY SalesPersonID
  )
SELECT
  sp.FirstName + ' ' + sp.LastName AS FullName,ts.NetSales
FROM Sales.vSalesPerson AS sp
  INNER JOIN cteTotalSales AS ts
    ON sp.BusinessEntityID = ts.SalesPersonID
ORDER BY ts.NetSales DESC

解决方法

没有内置,找到和替换可以与正则表达式一起使用,某些人可能会有一个解决方案.
原文链接:https://www.f2er.com/mssql/75491.html

猜你在找的MsSQL相关文章