Truncate Table TMP set Nocount on declare @OuterRun int = 1 -- Inserts The Next record declare @InnerRun int = 2 -- Update The result for the current record declare @num int = 2 -- The Number To Multiply For Each Column declare @duplicator int = 1 -- The Number To Multiply With declare @col_name varchar(10) -- Column Name Taken From sys.columns declare @cmd_insert varchar(100) -- Cmd To Insert The First Record For Each Row declare @cmd_update varchar(100) -- Cmd To Update Each Column set @col_name = (select name from sys.columns where object_id = object_id('TMP') and column_id = 1) set @cmd_insert = 'Insert Into TMP(COL1) values ('+cast(@OuterRun as varchar(10))+')' while (@OuterRun <= 9) begin exec (@cmd_insert) while (@InnerRun <= 9) begin --print Cast(@InnerRun as char(10)) + 'A' set @col_name = (select name from sys.columns where object_id = object_id('TMP') and column_id = @InnerRun) set @cmd_update = 'Update TMP set ' + @col_name + ' = ' + Cast(@InnerRun * @duplicator as varchar(10)) + ' Where COL1 = ' + Cast(@OuterRun as varchar(10)) exec (@cmd_update) set @InnerRun = @InnerRun + 1 end set @InnerRun = 2 set @duplicator = @duplicator + 1 set @OuterRun = @OuterRun + 1 set @cmd_insert = 'Insert Into TMP(COL1) values ('+cast(@OuterRun as varchar(10))+')' end select * from TMP; -------------------------------------------------------------------------------------------- -- Create Table With 9 Columns create table #TMP ( Col1 int, Col2 int, col3 int, col4 int, col5 int, col6 int, col7 int, col8 int, col9 int )