Category : SQL

Home » Archive by category : SQL

https://franch..

Read more

If you write SQL queries often, you should have probably used the IN operator which determines if a specified value matches any value in a list or a subquery. Below is the most simple use-case with single value, for examle:

  But one thing that you might not know is that you can use ..

Read more

[crayon-5b4db9ffef3bb82352290..

Read more

[crayon-5b4db9ffef5518..

Read more

[crayon-5b4db9ffef6993..

Read more

[crayon-5b4db9ffef7f69..

Read more

http://www.sql-server-helper.com/sql-server-2008/sql-server-2008-date-f..

Read more

The following script uses the CONVERT() function to display different formats. We will use the GETDATE() function to get the current date/time: CONVERT(VARCHAR(19),GETDATE())CONVERT(VARCHAR(10),GETDATE(),10)CONVERT(VARCHAR(10),GETDATE(),110)CONVERT(VARCHAR(11),GETDATE(),6)CONVERT(VARCHAR(11),GETDATE(),106)CONVERT(VARCHAR(24),GETDATE(),113) The result would look something like this: Nov 04 2011 11:45 PM11-04-1111-04-201104 Nov 1104 Nov 201104 Nov 2011 11..

Read more

Following query will run respective to today’s date. It will return Last Day of Previous Month, First Day of Current Month, Today, Last Day of Previous Month and First Day of Next Month respective to current month. DECLARE @mydate DATETIMESELECT @mydate = GETDATE()SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(@mydate)),@mydate),101) ,’Last Day of Previous Month’UNIONSELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(@mydate)-1),@mydate),101) AS Date_Value,’First Day of Current ..

Read more