Thursday, January 6, 2011

Insert data from one table to another table

You can insert the data from one table to another table using SELECT INTO and INSERT INTO with SELECT.. FROM clause.


-- Below statement will create the temp table to insert records
select * INTO #tmpObjects from sys.sysobjects where type = 'u'

-- Below statement will create the user table to insert records.
-- First will create the table and insert it details as well in new table
select * INTO tmpObjects from sys.sysobjects where type = 'u'

--Below statement will insert new data into table
insert into tmpObjects SELECT * from sys.sysobjects where type = 's'


1 comment:

  1. hi jugalbhai how are you??

    i have subscribed your blog post its good and giving me nice ways to finish ma jobs
    nice job keep it up..................
    that yesterdays blog 'GO '(we can modify batch separator) was very nice i tried...


    Kamesh

    ReplyDelete