[轉(zhuǎn)帖]sqlserver數(shù)據(jù)庫中把一張表中的數(shù)據(jù)復制到另一張表中
當前位置:點晴教程→知識管理交流
→『 技術(shù)文檔交流 』
1.自動創(chuàng)建新表跟原表一樣的結(jié)構(gòu),并復制數(shù)據(jù)(table2不用存在,會自動創(chuàng)建) select * into table2 from table1 2.復制table1的數(shù)據(jù)到table2(前提:table2必須已經(jīng)存在) insert into table2 select * from table1 3.只復制部分表結(jié)構(gòu)到新表 select id,name into table2 from table1 where 1= 2 where 1= 2表示條件不成立,條件不成立的情況下,只復制表的結(jié)構(gòu)。 4.如果跨服務器,復制數(shù)據(jù)庫某一個表到另一個數(shù)據(jù)庫中 select * INTO [SMSDB].[dbo].[SysLog] from openrowset('sqloledb','目標服務器';'賬號';'密碼',[SMSDB].[dbo].[SysLog]) 將數(shù)據(jù)庫目標服務器中的SysLog表復制本地的數(shù)據(jù)庫SMSDB中 如果出現(xiàn)以下錯誤: 解決方法: 系統(tǒng)管理員可以在本地SQL中通過使用 sp_configure 啟用 'Ad Hoc Distributed Queries' exec sp_configure 'show advanced options',1 reconfigure exec sp_configure 'Ad Hoc Distributed Queries',1 reconfigure 使用完成后,關閉Ad Hoc Distributed Queries: exec sp_configure 'Ad Hoc Distributed Queries',0 reconfigure exec sp_configure 'show advanced options',0 reconfigure ———————————————— 版權(quán)聲明:本文為CSDN博主「susu1083018911」的原創(chuàng)文章,遵循CC 4.0 BY-SA版權(quán)協(xié)議,轉(zhuǎn)載請附上原文出處鏈接及本聲明。 原文鏈接:https://blog.csdn.net/susu1083018911/article/details/129725048 該文章在 2023/5/23 15:58:58 編輯過 |
關鍵字查詢
相關文章
正在查詢... |