In this video, we are going to understand Tally table which is very useful in writing set based SQL queries. You can download the script which can be used to create the Tally table from below the video.
--Creating database SetBasedApproach CREATE DATABASE SetBasedApproach GO --Started using database SetBasedApproach USE SetBasedApproach GO --Creating tally table CREATE TABLE dbo.Tally ( N INT NOT NULL PRIMARY KEY ) --Adding records INSERT INTO dbo.Tally(N) SELECT TOP 100000 ROW_NUMBER() OVER(ORDER BY (SELECT NULL)) AS N FROM master.sys.all_columns Tbl1 CROSS JOIN master.sys.all_columns Tbl2
Rate This
[Total: 2 Average: 5]