Enumerations in T-SQL, is this possible?

We all know the function of a system function DATEADD(as an example). This function has 3 parameters, which are so strange to me. I searched Google for so long to find out the type of parameter of the first parameter (which is shown varcharin the object browser window), but did not find anything!

I think this is kind of Enum used in this function, because using it is very similar to using Enum:

Print DATEADD(DAY,1,GETDATE()) -- What that DAY?

My question can be answered if the answer to one of these questions:

  • How can I determine the definition of system functions?
  • What is this DAYin the instructions above and how can I write a function such as DATEADDto accept such a parameter?
  • If this is an enumeration, how can I define an enumeration in TSQL?
+4
source share
1 answer

Day is a type, and its values ​​can be:

yy, yyyy: year
qq, q: quarter
mm, m: month
dy, y: day of year
dd, d: day
wk, ww: week
dw, w: weekday
hh: hour
mi, n: minute
ss or s: second
ms: millisecond
mcs: microsecond
ns: nanosecond
+1
source

Source: https://habr.com/ru/post/1598650/


All Articles