[轉(zhuǎn)帖]sqlserver數(shù)據(jù)庫(kù)中把一張表中的數(shù)據(jù)復(fù)制到另一張表中
當(dāng)前位置:點(diǎn)晴教程→知識(shí)管理交流
→『 技術(shù)文檔交流 』
1.自動(dòng)創(chuàng)建新表跟原表一樣的結(jié)構(gòu),并復(fù)制數(shù)據(jù)(table2不用存在,會(huì)自動(dòng)創(chuàng)建) select * into table2 from table1 2.復(fù)制table1的數(shù)據(jù)到table2(前提:table2必須已經(jīng)存在) insert into table2 select * from table1 3.只復(fù)制部分表結(jié)構(gòu)到新表 select id,name into table2 from table1 where 1= 2 where 1= 2表示條件不成立,條件不成立的情況下,只復(fù)制表的結(jié)構(gòu)。 4.如果跨服務(wù)器,復(fù)制數(shù)據(jù)庫(kù)某一個(gè)表到另一個(gè)數(shù)據(jù)庫(kù)中 select * INTO [SMSDB].[dbo].[SysLog] from openrowset('sqloledb','目標(biāo)服務(wù)器';'賬號(hào)';'密碼',[SMSDB].[dbo].[SysLog]) 將數(shù)據(jù)庫(kù)目標(biāo)服務(wù)器中的SysLog表復(fù)制本地的數(shù)據(jù)庫(kù)SMSDB中 如果出現(xiàn)以下錯(cuò)誤: 解決方法: 系統(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 使用完成后,關(guān)閉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)載請(qǐng)附上原文出處鏈接及本聲明。 原文鏈接:https://blog.csdn.net/susu1083018911/article/details/129725048 該文章在 2023/5/23 15:58:58 編輯過 |
關(guān)鍵字查詢
相關(guān)文章
正在查詢... |