A lot of my colleagues and people in my network reached out to me to train them on the SQL Server and T-SQL. They think that my style of teaching and explaining the topic is unique and helps them understand the topic quickly. This really motivated me to take up a project of writing a … Continue reading Book Launch: Learn T-SQL from Scratch
Tag: T-SQL
Script to create copies of the existing object
Many a time we need copies of an object but with different names. I also got a requirement to process the files in parallel using SSIS. We had already implemented the parallelism, but at the entity level. For example, if there are 5 entities such as Customer, Product, Order, Transaction, Balance etc. then we had … Continue reading Script to create copies of the existing object
Divide the rows of a column in equals batches in grid format
I published an article Divide the rows in equals batches few days ago. One of my reader requested me to help him with a requirement to divide a column's data in equal groups and batches in grid format. I came up with a script which accepts the dynamic group size and divides the column data … Continue reading Divide the rows of a column in equals batches in grid format
Divide the rows in equals batches
Here is a simple and practical use-case of the NTILE function. We've used it to divide the rows of sys.columns into N groups. N is the number of groups. We've used the number of groups as 7. So the entire rows will be aligned equally to any of the group between 1 to 7. When … Continue reading Divide the rows in equals batches
Get the month end dates of last N years
Here is a simple T-SQL script that may come handy if you need the month end dates of last N years. N is the number of years. /* Assign the dynamic number of years here. You can write a procedure / table-valued function to accept this value as a parameter. */ DECLARE @Last_N_Years INT = … Continue reading Get the month end dates of last N years