Advertisement
WorkAkkaunt

Функция определения месяца

Aug 21st, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 1.26 KB | None | 0 0
  1. USE [oktell]
  2. GO
  3. /****** Object:  UserDefinedFunction [dbo].[GetTimeFromSecond]    Script Date: 07.08.2019 9:32:01 ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8.  
  9. -- =============================================
  10. -- Author:      <Author,,Name>
  11. -- Create date: <Create Date, ,>
  12. -- Description: <Description, ,>
  13. -- =============================================
  14.  
  15. CREATE FUNCTION dbo.GetMounthFromNum
  16.     (@MounthNum int)
  17.     RETURNS NVARCHAR(50) AS
  18.  
  19.     BEGIN
  20.             DECLARE @Months TABLE (
  21.             NUMBER INT
  22.            ,[Name] NVARCHAR(20)
  23.         )
  24.         INSERT INTO @Months
  25.             VALUES (1, 'Январь')
  26.         INSERT INTO @Months
  27.             VALUES (2, 'Февраль')
  28.         INSERT INTO @Months
  29.             VALUES (3, 'Март')
  30.         INSERT INTO @Months
  31.             VALUES (4, 'Апрель')
  32.         INSERT INTO @Months
  33.             VALUES (5, 'Май')
  34.         INSERT INTO @Months
  35.             VALUES (6, 'Июнь')
  36.         INSERT INTO @Months
  37.             VALUES (7, 'Июль')
  38.         INSERT INTO @Months
  39.             VALUES (8, 'Август')
  40.         INSERT INTO @Months
  41.             VALUES (9, 'Сентябрь')
  42.         INSERT INTO @Months
  43.             VALUES (10, 'Октябрь')
  44.         INSERT INTO @Months
  45.             VALUES (11, 'Ноябрь')
  46.         INSERT INTO @Months
  47.             VALUES (12, 'Декабрь');
  48.  
  49.  
  50.         RETURN (SELECT [Name] FROM @Months WHERE NUMBER = @MounthNum)
  51.  
  52.     END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement