This article explains the most commonly used and must-know SQL Server functions and techniques that help and are handy in daily .NET Development and working with SQL Server Database projects. I found that working knowledge of these functions are very helpful and used very often in software development.
Article Covers
- SYSDATETIME()
- DATEADD()
- DATENAME()
- DATEPART()
- DATEDIFF()
- DAY()
- MONTH()
- YEAR()
- DATALENGTH()
- APP_NAME()
- HOST_NAME()
- SYSTEM_USER
- SCOPE_IDENTITY
- @@VERSION
Returns a datetime2(7) value that contains the date and time of the computer on which the instance of SQL Server is running.
Syntax : SYSDATETIME()
Return Type : datetime2(7)
Note : SYSDATETIME and SYSUTCDATETIME have more fractional seconds precision than GETDATE and GETUTCDATE. SYSDATETIMEOFFSET includes the system time zone offset. SYSDATETIME, SYSUTCDATETIME, and SYSDATETIMEOFFSET can be assigned to a variable of any of the date and time types.
SELECT SYSDATETIME()
Output : 2015-08-16 09:49:22.163 (more…)