1樓:錢多多
insert語句需要指定列名,不能直接寫insert into book values...列名中排除主鍵自增欄位,無論是否設定了identity_insert的屬性值,應該都能成功的。
2樓:網友
有自增列,注意看看漏了哪個自增欄位。
僅當使用了列列表並且 identity_insert 為 on 時,才能為表'dbo.cangchuchayi'中的標識列指定顯式值。
3樓:網友
如提示所示啊,你匯入的表中有標識列,標識列只有identity_insert 為 on 時。
才能顯示的新增,你在select * 中把*改成列名,去掉標識列就可以了。
如果是需要新增的,那麼用set identity_insert cangchuchayi on
來開啟開關,但是需要顯示指定列名,即insert into 表(列名1...
插入後用off關閉。
4樓:喜歡種蘑菇
這個問題是因為在你要插入的新表裡,有一列是標識列,例如自增這樣的。所以會導致在插入資料的時候報錯,因為不能往標識列裡插入資料。
解決方法:例如乙個sql語句,insert into a表名 select * from b表名。
b表有列1,2,3,列1在a表裡是標識列(如自增),正確語句應該是insert into a表名 select 列2,列3 from b表名。
5樓:李響知道
select*from 是查詢所有,而insert into 表名 values()這才是插入啊。
僅當使用了列列表並且 identity_insert 為 on 時,才能為表'stulnfo'中的標識列指定顯式值。
6樓:xummer_昔年
操作步驟:
首先建立乙個有標識列的表:create table products (id int identity primary key, product varchar(40))
嘗試在表中做以下操作:insert into products (id, product) values(3, 'garden shovel')結果會導致錯誤:「當 identity_insert 設定為 off 時,不能向表 'products' 中的標識列插入顯式值。
改用:set identity_insert products oninsert into products (id, product) values(1, 'garden shovel')返回正確。
建立另外乙個表products2,嘗試相同插入操作:create table products2 (id int identity primary key, product varchar(40))然後執行:set identity_insert products2 oninsert into products2 (id, product) values(1, 'garden shovel')導致錯誤:
表 '' 的 identity_insert 已經為 on。無法對錶 'products2' 執行 set 操作。」改為執行:
set identity_insert products offset identity_insert products2 oninsert into products2 (id, product) values(2, 'garden shovel')執行通過。
嘗試以下操作:set identity_insert products2 oninsert into products2 select * from products導致錯誤:「僅當使用了列的列表,並且 identity_insert 為 on 時,才能在表 'products2' 中為標識列指定顯式值。
改為:set identity_insert products2 oninsert into products2 (id, product) select * from products執行通過。
7樓:網友
對的。插入資料時,自增長列是系統自動處理,不需要你來指定數值,你也指定不了。只有將identity_insert 為 on 時插入資料時,自增長列你才可以指定乙個值。
比如我有乙個表pz,有如下列xh,id,inx,kmid,fzzid,code ,jfje,dfje,rq,zy其中xh是自增長,正常插入資料時。
insert pz (id,inx,kmid,fzzid,code ,jfje,dfje,rq,zy) values(..不需要指定xh列。如果將identity_insert開啟。
set identity_insert pz on
插入資料時就可以給xh列指定值。
insert pz (xh,id,inx,kmid,fzzid,code ,jfje,dfje,rq,zy) values(指定表中沒有的數值,24389,3,1524,1,'0109',0,0,'','jk')
關閉identity_insert
set identity_insert pz off
僅當使用了列列表並且 identity_insert 為 on 時,才能為表'lzp.訂購單明細'中的標識列指定顯式值。
8樓:一顆程式猿
如果要向identity列中顯式插入值, 除了設定identity_insert 意外, 還要求列出插入表中的列,必須是: insert into 表(列1,列2,列3) values(..這樣, 前面的列的列表是不可以省略的。
僅當使用了列的列表,並且 identity_insert 為 on 時,才能在表 '學生資訊' 中為標識列指定顯式值。
9樓:
您的表有一列是自增長的標識列,比如第一列是,您需要使用這樣的格式:
insert into 學生資訊(欄位2,欄位3,欄位4,欄位5,欄位6) values('張飛','男',200801,18,'團員',2008-3-1)
僅當使用了列列表並且 identity_insert 為 on 時,才能為表'tb_user'中的標識列指定顯式值。
10樓:匿名使用者
既然你插入的是null,那就不要插入嘛。弄了半天你插入乙個空值,還有如果建立了主鍵,這些值又必須不能重複。如果一定要插入,先去掉該列的主鍵和聚集索引看看。
11樓:匿名使用者
自動標識列放在前面新增的時候不用寫的都會自動新增。
僅當使用了列列表並且 identity_insert 為 on 時,才能為表'goods'中的標識列指定顯式值。
12樓:小墨丶
insert into goods(列名1,列名2,..values('','',..還需要指定列名,把列名寫上。
我把id設為自增後,就出現了:僅當使用了列列表並且 identity_insert 為 on 時,才能為表'area'中的標識列
13樓:網友
這個很簡單。 只要在 sql 語句裡面,把那個 自增id 的列, 從 insert into 的語句中間刪除掉就可以了。
例如原先的 sql 是。
insert into 表 ( id, name, other) values( 1, 'test', 'haha');
當 id 這一列,被修改成 自增列, 也就是 identity 之後。
插入的sql要修改為:
insert into 表 ( name, other) values( 'test', 'haha');
關於 sql server 裡面,自增列如何處理的一些例子,可參考。
14樓:小蘭看動漫
..那麼多的id你刪的完?
方法1.還不與手動操作,將表刪除,然後將表的自增長的列幹掉,執行**後改回。
方法2.用工具,很簡單。
15樓:網友
set identity_insert
允許將顯式值插入表的標識列中。
語法 set identity_insert [ database.[ owner.]
引數 database
是指定的表所駐留的資料庫名稱。
owner是表所有者的名稱。
table是含有標識列的表名。
執行下這個ⅷ
16樓:網友
id設為自增後,insert語句裡面就不能含有id欄位了,否則就不叫「自」增長了。你說你的資料庫在另一臺電腦上可以,有沒有可能你「id設為自增」的動作沒有在那臺電腦上實施過?既然你的id改為自增了,相關的insert語句是一定要改的,如果你沒有改,一定會有問題。
identity_insert 為 on 可以把自增臨時關掉,但是一般是在初始化表資料的時候採用,而真正執行程式的時候不用,並且完了要設回identity_insert 為 off。
有問題hi我吧。
杜甫的《登高》使用了那些意象杜甫的《登高》使用了那些意象?營造了那些意境?
意象 風,天,猿,渚,沙,鳥,落木,長江,霜鬢,酒杯。原文 登高 唐 杜甫 風急天高猿嘯哀,渚清沙白鳥飛回。無邊落木蕭蕭下,不盡長江滾滾來。萬里悲秋常作客,百年多病獨登臺。艱難苦恨繁霜鬢,潦倒新停濁酒杯。拓展資料 譯文 天高風急猿聲悽切悲涼,清澈水中群鷗嬉戲盤旋。無窮無盡的樹葉紛紛落,長江滾滾湧來奔...
暫列金額如何使用 暫列金額有哪些作用?
採用工程量清單計價的工程,暫列金額按招標檔案編制,列入其他專案費。採用工料單價計價的工程,暫列金額單獨列項計算。暫列金額是業主方的備用金,這是由業主的諮詢工程師事先確定並填入招標檔案中的金額。暫列金額應由監理人報發包人批准後指令茄肆全部或部分地使用,或者根本不予使用。對於經發包人批准的每一筆暫列金額...
使用了無效的安全證書該證書僅對,使用了無效的安全證書。 該證書僅對 alicdn com 有效。 (錯誤碼 ssl error bad cert domain)
你訪問的 域名和安全證書中的 不匹配,所以會顯示 該證書僅對 alicdn.有效 可能是安裝的時候配置錯了 證書安裝時候經常會出現這樣那樣的問題,還是找專業的技術人員幫忙比較靠譜,gdca就不錯,專業的機構,比自己操作省事兒 使用了無效的安全證書該證書僅對 alicdn.有效。錯誤碼 ssl err...