• Try this:

    if object_id('tempdb..#table1') IS NOT NULL DROP TABLE #table1;

    if object_id('tempdb..#table2') IS NOT NULL DROP TABLE #table2;

    if object_id('tempdb..#table3') IS NOT NULL DROP TABLE #table3;

    create table #table1 (col1 int,col2 varchar(30));

    insert into #table1 values (1,'martin');

    insert into #table1 values (2,'tom');

    insert into #table1 values (3,'schrof');

    create table #table2(t_col1 int identity(1,1),t_col2 int);

    create table #table3 (f_col1 int identity(1,1),f_col2 varchar(30),f_col3 int);

    insert into #table2 (t_col2) output inserted.t_col1, inserted.t_col2 into #table3(f_col2,f_col3)

    select col1 from #table1 t;

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2