SQL Beautifier & SQL2014自带的格式化工具
格式化工具(希望有几款集成在IDE中的格式化工具)
为什么要说明这些,不是为说明这个工具而发,看到那几千行或集成在一起的存储过程觉得乱七八的不爽,后面将会强力训练下自己。
--下面这款SQL Beautifier集成的虽好,似乎要收费的,试用吧(也有独立版的,但使用起来不方便)
---------------------------------比较一下,行数越多,一个字段就占一行,看起来清楚但却不方便-------------------------
/****** Object: StoredProcedure [dbo].[check_in] Script Date: 2020-05-22 20:54:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[Check_in]
AS
SELECT Pass,
NAME,
[User],
[Right],
Ki,
quanxian,
b.userType,
bAppPos,
dDatetime=CONVERT(VARCHAR(100), Getdate(), 23),
a.cStoreNo,
a.cStoreName,
c.cParentNo
FROM t_Store_userType a,
t_Pass b,
t_Store c
WHERE a.userno = b.[User]
AND a.cStoreNo = c.cStoreNo
UNION
SELECT Pass,
NAME,
[User],
[Right],
Ki,
quanxian,
userType,
bAppPos,
dDatetime=CONVERT(VARCHAR(100), Getdate(), 23),
a.cStoreNo,
a.cStoreName,
b.cParentNo
FROM dbo.t_Pass a,
t_Store b
WHERE a.cStoreNo = b.cStoreNo
UNION
SELECT Pass,
NAME,
[User],
[Right],
Ki,
quanxian,
userType,
bAppPos,
dDatetime=CONVERT(VARCHAR(100), Getdate(), 23),
a.cStoreNo,
a.cStoreName,
b.cParentNo
FROM dbo.t_Pass a,
t_PsStore b
WHERE a.cStoreNo = b.cStoreNo
GO
----------------------------------------------------------------------------------------------------------------------------------------------
下面这个是MSSQL2014自带的格式工具,似乎不能全选格式化,只能对DML(select,insert,delete,update)格式化,
将格式化工具显示在快捷工具栏上方法: SQLFormatter Options\Add or remove command\Customize\Design Query in Editor
GO
/****** Object: StoredProcedure [dbo].[check_in] Script Date: 2020-05-22 20:54:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROC [dbo].[Check_in]
AS
SELECT Pass, NAME, [User], [Right], Ki, quanxian, b.userType, bAppPos, CONVERT(VARCHAR(100), GETDATE(), 23) AS dDatetime, a.cStoreNo, a.cStoreName,
c.cParentNo
FROM t_Store_userType AS a CROSS JOIN
t_Pass AS b CROSS JOIN
t_Store AS c
WHERE (a.userno = b.[User]) AND (a.cStoreNo = c.cStoreNo)
UNION
SELECT Pass, NAME, [User], [Right], Ki, quanxian, userType, bAppPos, CONVERT(VARCHAR(100), GETDATE(), 23) AS dDatetime, a.cStoreNo, a.cStoreName,
b.cParentNo
FROM t_Pass AS a CROSS JOIN
t_Store AS b
WHERE (a.cStoreNo = b.cStoreNo)
UNION
SELECT Pass, NAME, [User], [Right], Ki, quanxian, userType, bAppPos, CONVERT(VARCHAR(100), GETDATE(), 23) AS dDatetime, a.cStoreNo, a.cStoreName,
b.cParentNo
FROM t_Pass AS a CROSS JOIN
t_PsStore AS b
WHERE (a.cStoreNo = b.cStoreNo)
GO
--------------------------------------------------------------------------------------------------------------------------------------
之前试用MSSQL2014,没注意到快捷键不可用, 降低MSSQL2008后再返回到MSSQL2014时,
发现此, 可在SSMS菜单中: Tools\Import and Export settings,导入MSSQL2008的习惯性设置即可
--------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------