

Get the First Day of the Current Month
To get the first date of the current month, you could a query similar to the following: SELECT CONVERT(VARCHAR(25),DATEADD(DAY,-(DAY(GETDATE())) +1, GETDATE()), 105) Day1;
To get the first date of the current month, you could a query similar to the following: SELECT CONVERT(VARCHAR(25),DATEADD(DAY,-(DAY(GETDATE())) +1, GETDATE()), 105) Day1;
Get all the tables with a count of their records with the following query: CREATE TABLE #Temp ( TableName VARCHAR(MAX), Rows INT ); EXEC sp_MSForEachTable @command1 = ‘INSERT INTO #Temp(TableName,
If you want to do statistics in SQL, the following tests will be very useful to look into: Pearson’s Correlation Kendall’s Tau Rank Correlation Simple Linear Regressions The Kruskal-Wallis Test
Working with and comparing multiple queries at the same time can be a pain, at least for me. Two independent query windows take up more space on screen, or having
Sometimes you want to select all the columns, without using the *. Specifying column names speeds up your query. The problem comes in with large tables or tables with difficult
I hate repetitive tasks. I am not a robot. However, the problem is that there are some tasks that can be quite repetitive or just take too many steps to
This is a neat trick I have learnt recently. When dealing with large lists of information, we, as developers, sometimes need to copy them, then add commas manually. Say, for
We can get all columns in all tables of a specific data type. The example below gets all INT columns in the entire database SELECT OBJECT_NAME(sys.columns.OBJECT_ID) as TableName, sys.columns.name as
For building faster SQL queries, follow these hints. 1. Use Smaller batches Always try to delete data or update data in smaller batches. If you try to delete thousands of