av激情亚洲男人的天堂国语,日韩欧美精品一中文字幕,无码av一区二区三区无码,国产又色又爽又刺激的a片,国产又色又爽又刺激的a片

SQLServer自增字段插入值的實(shí)際操作

在實(shí)際操作中我們經(jīng)常會(huì)遇到向SQL Server自增字段插入值的這一狀況,以下的文章主要向大家描述的是向SQL Server自增字段插入值的實(shí)際操作步驟,在一般的情況下,不能直接向 SQL Server 數(shù)據(jù)庫的自增字段插入值。

如果非要這么干的話,SQL Server 就會(huì)好不客氣地給你個(gè)錯(cuò)誤警告:

 
 
 
 
  1. Server: Msg 544, Level 16, State 1, Line 1
  2. Cannot insert explicit value for identity column in table 't' when identity_insert is set to OFF.

這個(gè)錯(cuò)誤消息提示我們,如果向 SQL Server 自增字段插入值,需要設(shè)置 identity_insert 選項(xiàng)為 on。

 
 
 
 
  1. set identity_insert on

看具體的一個(gè)例子:

 
 
 
 
  1. create table dbo.t
  2. (
  3. id int identity(1,1) not null,
  4. name varchar(50)
  5. )
  6. set identity_insert t on
  7. insert into t (id, name) values(1, 'sqlstudy')
  8. set identity_insert t off

注意的是,自增字段插入值后,要及時(shí)把 identity_insert 設(shè)置為 off。

上述的相關(guān)內(nèi)容就是對(duì)SQL Server自增字段插入值的描述,希望會(huì)給你帶來一些幫助在此方面。

以上的相關(guān)內(nèi)容就是對(duì)SQL Server自增字段插入值的介紹,望你能有所收獲。


網(wǎng)站名稱:SQLServer自增字段插入值的實(shí)際操作
鏈接地址:http://uogjgqi.cn/article/cdghico.html
掃二維碼與項(xiàng)目經(jīng)理溝通

我們?cè)谖⑿派?4小時(shí)期待你的聲音

解答本文疑問/技術(shù)咨詢/運(yùn)營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流