小編給大家分享一下SQLServer數(shù)據(jù)庫中不同數(shù)據(jù)庫相同表結(jié)構(gòu)可以相互導(dǎo)入嗎,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
在SQLServer數(shù)據(jù)庫下,新建兩個不同的數(shù)據(jù)庫名字,然后在數(shù)據(jù)庫下創(chuàng)建兩個相同結(jié)構(gòu)的表(建議使用SQL語句),比如:
在soutest數(shù)據(jù)庫下寫入以下語句:
createtableEmployee1(EmployeeIDintprimarykey,EmployeeNamevarchar(20)notnull,EmployeeAgesmallintnotnull,EmployeeSexchar(2)default'女',EmployeeCellPhoneintnotnull,EmployeeAddressnvarchar(50),EmployeeCommentsnvarchar(1000))
然后往這個表中插入數(shù)據(jù)(注:假如在源表中設(shè)置了標(biāo)識符的,請在下面語句前加入setidentity_inserton,最后加入setidentity_insertoff):
SQLServer數(shù)據(jù)庫中不同數(shù)據(jù)庫相同表結(jié)構(gòu)可以相互導(dǎo)入嗎
insertintoEmployee(EmployeeID,EmployeeName,EmployeeAge,EmployeeCellPhone,EmployeeAddress,EmployeeComments)values(2,'xd',12,123455,'beijing','handsomeman')insertintoEmployee(EmployeeID,EmployeeName,EmployeeAge,EmployeeCellPhone,EmployeeAddress,EmployeeComments)values(3,'xwxe',12,123455,'shanghai','agoodboy')
我們將在test下創(chuàng)建表的語句放在另一個數(shù)據(jù)庫destest下執(zhí)行,這時,我們建立了一個表。再在這個數(shù)據(jù)庫下執(zhí)行以下語句:
insertdestest.dbo.Employee(EmployeeID,EmployeeName,EmployeeAge,EmployeeSex,EmployeeCellPhone,EmployeeAddress,EmployeeComments)selectEmployeeID,EmployeeName,EmployeeAge,EmployeeSex,EmployeeCellPhone,EmployeeAddress,EmployeeCommentsfromsoutest.dbo.Employee
至此,工作全部結(jié)束。
以上是“SQLServer數(shù)據(jù)庫中不同數(shù)據(jù)庫相同表結(jié)構(gòu)可以相互導(dǎo)入嗎”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
新聞標(biāo)題:SQLServer數(shù)據(jù)庫中不同數(shù)據(jù)庫相同表結(jié)構(gòu)可以相互導(dǎo)入嗎-創(chuàng)新互聯(lián)
文章轉(zhuǎn)載:http://aaarwkj.com/article30/cdhppo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供動態(tài)網(wǎng)站、網(wǎng)站策劃、App開發(fā)、靜態(tài)網(wǎng)站、外貿(mào)建站、關(guān)鍵詞優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容