gFmtOpt.EmptyLines | Type: TEmptyLinesOption | Default: eloMergeIntoOne |
gFmtOpt.InsertBlankLineInBatchSqls | Type: boolean | Default: false |
gFmtOpt.NoEmptyLinesBetweenMultiSetStmts | Type: boolean | Default: true |
Original SQL:
CREATE FUNCTION dbo.isoweek (@DATE datetime)Example format options:
Name | Value |
gFmtOpt.EmptyLines | eloMergeIntoOne |
gFmtOpt.InsertBlankLineInBatchSqls | false |
Formatted SQL:
CREATE FUNCTION dbo.Isoweek
(@DATE DATETIME)
RETURNS INT
WITH EXECUTE AS caller
AS
BEGIN
DECLARE @ISOweek INT
SET @ISOweek = Datepart(wk, @DATE) + 1 - Datepart(wk, Cast(Datepart(yy, @DATE) AS CHAR(4)) + '0104')
--Special cases: Jan 1-3 may belong to the previous year
IF(@ISOweek = 0)
SET @ISOweek = dbo.Isoweek(Cast(Datepart(yy, @DATE) - 1 AS CHAR(4)) + '12' + Cast(24 + Datepart(DAY, @DATE) AS CHAR(2))) + 1
--Special case: Dec 29-31 may belong to the next year
IF((Datepart(mm, @DATE) = 12)
AND((Datepart(dd, @DATE) - Datepart(dw, @DATE)) >= 28))
SET @ISOweek = 1
RETURN(@ISOweek)
END
;
GO
Example format options:
Name | Value |
gFmtOpt.EmptyLines | eloMergeIntoOne |
gFmtOpt.InsertBlankLineInBatchSqls | true |
Formatted SQL:
CREATE FUNCTION dbo.Isoweek
(@DATE DATETIME)
RETURNS INT
WITH EXECUTE AS caller
AS
BEGIN
DECLARE @ISOweek INT
SET @ISOweek = Datepart(wk, @DATE) + 1 - Datepart(wk, Cast(Datepart(yy, @DATE) AS CHAR(4)) + '0104')
--Special cases: Jan 1-3 may belong to the previous year
IF(@ISOweek = 0)
SET @ISOweek = dbo.Isoweek(Cast(Datepart(yy, @DATE) - 1 AS CHAR(4)) + '12' + Cast(24 + Datepart(DAY, @DATE) AS CHAR(2))) + 1
--Special case: Dec 29-31 may belong to the next year
IF((Datepart(mm, @DATE) = 12)
AND((Datepart(dd, @DATE) - Datepart(dw, @DATE)) >= 28))
SET @ISOweek = 1
RETURN(@ISOweek)
END
;
GO
Example format options:
Name | Value |
gFmtOpt.EmptyLines | eloRemove |
gFmtOpt.InsertBlankLineInBatchSqls | false |
Formatted SQL:
CREATE FUNCTION dbo.Isoweek
(@DATE DATETIME)
RETURNS INT
WITH EXECUTE AS caller
AS
BEGIN
DECLARE @ISOweek INT
SET @ISOweek = Datepart(wk, @DATE) + 1 - Datepart(wk, Cast(Datepart(yy, @DATE) AS CHAR(4)) + '0104')
--Special cases: Jan 1-3 may belong to the previous year
IF(@ISOweek = 0)
SET @ISOweek = dbo.Isoweek(Cast(Datepart(yy, @DATE) - 1 AS CHAR(4)) + '12' + Cast(24 + Datepart(DAY, @DATE) AS CHAR(2))) + 1
--Special case: Dec 29-31 may belong to the next year
IF((Datepart(mm, @DATE) = 12)
AND((Datepart(dd, @DATE) - Datepart(dw, @DATE)) >= 28))
SET @ISOweek = 1
RETURN(@ISOweek)
END
;
GO
Example format options:
Name | Value |
gFmtOpt.EmptyLines | eloRemove |
gFmtOpt.InsertBlankLineInBatchSqls | true | gFmtOpt.NoEmptyLinesBetweenMultiSetStmts | true |
Formatted SQL:
SET @A = @B
SET @C = @D
SET @E = @F
SET @G = @H
Example format options:
Name | Value |
gFmtOpt.EmptyLines | eloRemove |
gFmtOpt.InsertBlankLineInBatchSqls | true | gFmtOpt.NoEmptyLinesBetweenMultiSetStmts | false |
Formatted SQL:
SET @A = @B
SET @C = @D
SET @E = @F
SET @G = @H