久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

沒有列名列表的tsql身份插入

tsql identity insert without column name list(沒有列名列表的tsql身份插入)
本文介紹了沒有列名列表的tsql身份插入的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我要將一些數據從一個數據庫轉儲到另一個數據庫.我正在使用

I am going to dump some data from one db to another one. I am using

set identity_insert MyTable on
GO
INSERT INTO MyTable SELECT * FROM sourceDB.dbo.MyTable
GO
set identity_insert MyTable off

無論如何要讓它發揮作用?有 30 個表,將列名列表添加到插入語句會很耗時.我使用的是 SQL server 2000.近期會升級到 SQL server 2008.

Is anyway to get this to work? There's 30 tables and it will be time consuming to add the list of column names to the insert statement. I am using SQL server 2000. Will be upgraded to SQL server 2008 in the near future.

MyTable 有一個標識列.

MyTable has an identity column.

推薦答案

只需從對象瀏覽器中拖放列名稱即可.您可以執行一個步驟,它比編寫 select * 需要大約 1 秒的時間,并且無論如何您都不應該在生產代碼中使用 select *.這是一個糟糕的做法.

Just drag and drop the column names from the object browser. You can do it one step it takes about 1 second longer than writing select * and you should never use select * in production code anyway. It is a poor practice.

不過,我擔心您插入 Identity 列,這是幾乎永遠不應該做的事情.如果原始表的某些標識列與新表中的現有 ID 相同,該怎么辦?在決定從另一個表插入 id 值之前,請務必檢查這一點.我更喜歡插入到父表并獲得一個新的 id 并將其與舊的 id 匹配(2008 年的輸出對此很好),然后將新的 id 用于任何子表,但加入舊的 id.

I am concerned about you inserting Identity columns though, this is something that should almost never be done. What if the original table had some identity columns that are the same as existing ids in the new table? Make sure to check for this before deciding to insert id values from another table. I prefer to do the insert to the parent table and get a new id and match it to the old id (output is good for this in 2008) and then use the new id for any child tables but join on the old id.

這篇關于沒有列名列表的tsql身份插入的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Converting Every Child Tags in to a Single Column with multiple Delimiters -SQL Server (3)(將每個子標記轉換為具有多個分隔符的單列-SQL Server (3))
How can I create a view from more than one table?(如何從多個表創建視圖?)
Create calculated value based on calculated value inside previous row(根據前一行內的計算值創建計算值)
How do I stack the first two columns of a table into a single column, but also pair third column with the first column only?(如何將表格的前兩列堆疊成一列,但也僅將第三列與第一列配對?) - IT屋-程序員軟件開發技
Recursive t-sql query(遞歸 t-sql 查詢)
Convert Month Name to Date / Month Number (Combinations of Questions amp; Answers)(將月份名稱轉換為日期/月份編號(問題和答案的組合))
主站蜘蛛池模板: 91视频在线观看 | 一级毛片视频在线 | 亚洲3级| 国产午夜精品久久久久免费视高清 | 欧美 中文字幕 | 日韩 国产 在线 | 国产欧美精品区一区二区三区 | 久久精品国内 | 久草在线在线精品观看 | 九色视频网站 | 日韩欧美一区二区三区免费观看 | 日韩在线看片 | 综合自拍| 久久久久黑人 | 337p日韩 | 日韩精品一区二区在线 | 亚洲经典一区 | 鸳鸯谱在线观看高清 | 欧美激情久久久 | 成人午夜电影在线观看 | 精品欧美一区二区精品久久久 | 久久久久久国产免费视网址 | 亚洲欧美一区二区三区视频 | 精品一区二区三区在线视频 | 日韩成人免费视频 | 久久中文免费视频 | 中文字幕一区二区三区四区五区 | 日本精品一区 | 欧美午夜精品 | 国产精品一区二区三区四区 | 中文二区| 你懂的在线视频播放 | 国产一区久久 | 欧美aⅴ | 成人精品国产免费网站 | 成人三区| 大香网伊人 | 亚洲在线一区二区 | www.日日干 | 精品久久久久久久久久久久 | 成人亚洲视频 |