WHAT'S NEW?
Showing posts with label SQL Server. Show all posts
Showing posts with label SQL Server. Show all posts
Had this requirement of reading the name and month value for one of our requirement today.
We used the easiest once -

DATEPART(month, Customer_joining_date)

this outputs the numeric month value. So if its January its 1, Feb then its 2.

DATENAME(month, Customer_joining_date)

this outputs the month name from the date time value. So if its in mm-dd-yyyy (08-26-1987 18:52:03:00) then it is will output's AUGUST.

SYSDATETIME() vs  GETDATE()

both of them will return the same current system date time but SYSDATETIME() will return that in DATETIME2 format with precision upto 7 digits.



Do you know- 


  • VARCHAR takes less amount of disk space to store than NVACHAR for the same string.
  • VARCHAR does not support unicode data. So, if I try to save a string that is in any other language than English, it fails to display it as is.
  • Thus NVARCHAR comes to our rescue in case we want to save unicode string variables/ literals.
  • If we run the execution plan for select statements that have VARCHAR and NVARCHAR, we will notice that NVARCHAR takes more time to than VARCHAR.


remember these simple things and design your database variables next time to save disk and save execution to be faster.
Happy coding.