一、導入數據的前提條件:
1、必需安裝SQL SERVER2008 企業管理器 ——(SQL SERVER 一般會簡稱成(chéng)MSSQL)
2、網絡必需穩定,如果網絡太慢客戶端的MSSQL管理器會出現假死狀态
二、需要了解的知識:
1、一個數據庫可以包含多個數據表、多個存儲過(guò)程、多個視圖、函數等;

2、一個數據表肯定包含了多條數據行,比如文章内容就存在數據表裡(lǐ);

3、視圖可以理解爲虛拟的數據表,這(zhè)個表的數據來自物理數據表,比如可以把三個表合成(chéng)一個視圖以便查詢;

4、存儲過(guò)程和函數是一段SQL腳本,它們大大增強了SQL語言的功能(néng)和靈活性;


通過(guò)以上的内容已經(jīng)大概了解了SQL數據庫需要的一些知識,下面(miàn)開(kāi)始來導數據。
三、數據導入的總體步驟:
1、在本機連接到遠程服務器。
2、在本機生成(chéng)SQL腳本,并把本機生成(chéng)的腳本放到遠程執行(這(zhè)一步會建好(hǎo)表結構存儲過(guò)程之類的,但沒(méi)有把表裡(lǐ)的數據行導進(jìn)去)。
3、導入數據表裡(lǐ)的數據(這(zhè)一步就是把本機數據表裡(lǐ)的數據行導入到遠程的數據表)。
注意:以下演示涉及到的地址、用戶名密碼等信息爲舉例說明,實際操作請按自己所取得的主機信息填寫。
例如:本地電腦上有個數據庫,這(zhè)個數據庫包含 "數據表"、"視圖"、"自定義函數"、"存儲過(guò)程",要把這(zhè)些都(dōu)導到遠程服務器。
例如:購買的主機MSSQL數據庫的遠程服務器信息是這(zhè)樣(yàng)的:
數據庫地址: hds100005678.my3w.com
數據庫用戶名:hds100005678
數據庫密碼:******
第一步:在本機連接到遠程服務器;


連接成(chéng)功後(hòu)可以看到在本機的MSSQL管理器上多了個服務器節點;

第二步:在本機生成(chéng)SQL腳本,并把本機生成(chéng)的腳本放到遠程執行;

點下一步後(hòu),選擇“選擇特定的數據庫對(duì)象”,注意不要勾擇“用戶”

點下一步後(hòu),選擇“保存到新建查詢窗口”;

點下一步;

點下一步;

點完成(chéng)之後(hòu),會自動打開(kāi)一個SQL腳本的窗口;

選中遠程服務器連接節點;

點“新建查詢”;

點擊新建查詢之後(hòu),右側會出現一個空白的窗口的“遠程窗口”

把“本機窗口”的SQL腳本全選複制到“遠程窗口”上,再把第一行删除;

點擊“執行”按鈕;

點完執行之後(hòu),等一下可以看到成(chéng)功完成(chéng)的提示;

經(jīng)過(guò)以上的操作,在遠程節點上,可以看到已經(jīng)成(chéng)功的把數據庫表、存儲過(guò)程、函數、視圖導入成(chéng)功了,但數據表裡(lǐ)是空的,還(hái)需要把表裡(lǐ)的内容導進(jìn)去;

第三步:導入本機數據表裡(lǐ)的數據行到遠程
下面(miàn)準備把表裡(lǐ)的數據導入到遠程。
選中遠程節點上hds100005678 的數據庫,右鍵-----任務---導入數據 (注意這(zhè)個是遠程節點上的數據庫);


選擇要從那裡(lǐ)複制數據到遠程(要從本機的數據庫複制數據,“.”号代表本機);

選擇要把本機的數據複制到何處,要導入到遠程服務器,點下一步;

選第一項“複制一個或多個表或視圖的數據”,點下一步;

選中要導入的表,注意不要選視“視圖”(前面(miàn)相關知識裡(lǐ)有提到:視圖可以理解爲虛拟的數據表,這(zhè)個表的數據來自物理數據表,所以隻要選物理表);

(不用一個一個選表,技巧)

點完“編輯映射”後(hòu),會彈出下圖框;

确定再點下一步;

點“完成(chéng)按鈕”;

請耐心等待數據導入過(guò)程;

導入完成(chéng)後(hòu),點擊完成(chéng)按鈕;

至此將(jiāng)本地計算機數據庫導入到遠程服務器的操作完成(chéng)。