Hi Guys,
Last time i watch in the forums, one gentleman ask the question , how to insert records to one table from the another table in Sql Server.
This actually simple. and we can do this two ways.
1.normal way
insert into desttableName select * from databaseName.dbo.sourceTableName;
2.You can use the OpenRowSet also
INSERT INTO YourTableName
SELECT *
FROM OPENROWSET(BULK 'SQLNCLI', 'Server=(local);Trusted_Connection=yes;', 'SELECT Columns FROM Database.Schema.Tablename ORDER BY columns)
Thank you
Keep It Watch
Subscribe to:
Post Comments (Atom)
If you want to create a temporary table which contains few records from another table, you can create and insert the records in one step as below.
ReplyDeletecreate table aa_tmp AS
select *
from inventory_part_tab
where contract = 'A-S1';