如何用SQL語句複製表和表中的數據?


--如何用SQL語句複製表和表中的數據?

select * into copytable from table1

--table1    源表

--copytable    要複製的表

sql 2005表的複製有兩種:一種就是把整個表複製過去,就好像複製文件並且重命名。別外一種就是把表的內容複製過出. 
select * into newtable form oldtable;把oldtabel複製到newtable且newtable不存在,否則出錯.;

insert into newtable select * from oldtable把oldtable的內容插入到newtable, newtable一定要存在,纔可以複製.不同數據庫間複製表
if object_id('test') is not null drop synonym test
create synonym test for test.dbo.vdwl_product
select * into vdwl_product from test
select * from vdwl_product
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章