Summary on 20080701: insert value for identity column in sql
来源:互联网 发布:windowsxp主题仿mac 编辑:程序博客网 时间:2024/04/29 01:39
In MSSQLServer, by default, user can‘t insert/assign/update value for identity column; SQLServer will do this for user automatically, so there is one problem caused that: what will do if wants to assign value for identity column? for one table like: teacher(teacher_id, teacher_name, teacher_age), and teacher_id is identity the insert should be like: insert into teacher values('kalash',12), that's correct format, if insert is like: insert into teacher values(1,'kalash',12), there will be error when execute the statement
and for the case that user want to insert value for identity column, user can turn on the identity_insert for implicitly insert, the code is as followed:
set identity_insert [table_name] oninsert into teacher(teacher_id, teacher_name)values(1,'klasch');set identity_insert [table_name] off
for the above code, please note that: 1. for the insert, the column name should be listed out, especially the 'teacher_id' 2. any time, the 'identity_insert' can be set to 'on' for only one table, if the 'identity_insert' is set to 'on' and set that for another table, there will be error, so for tip3 3. it's suggested that every time after set the identity_insert to be 'on', set it back to 'off' after the operation
- Summary on 20080701: insert value for identity column in sql
- Cannot insert explicit value for identity column in table 'settings' when IDENTITY_INSERT is set to OFF.
- Cannot insert explicit value for identity column in table 'settings' when IDENTITY_INSERT is set to OFF.
- Cannot insert explicit value for identity column in table ‘table’ when IDENTITY_INSERT is set to OFF
- Cannot insert explicit value for identity column in table 'TableNa' when IDENTITY_INSERT is set to O
- An explicit value for the identity column in table 'users' can only be specified when a column list
- How To: Reset Identity column in SQL Server
- java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a LONG column
- java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a LONG column
- Change Not For Replication Value for SQL Server Identity Columns
- Insert the self-growth (IDENTITY) column
- Refreshing One Column based on the value of Another Column in ADFdi Table
- Summary on 20081111: system method in sql server2005
- ORA-01461: can bind a LONG value only for insert into a LONG column
- ORA-01461: can bind a LONG value only for insert into a LONG column
- ORA-01461: can bind a LONG value only for insert into a LONG column 问题解决方案
- hibernate错误:ORA-01461: can bind a LONG value only for insert into a LONG column
- ORA-01461: can bind a LONG value only for insert into a LONG column
- SSH框架中的使用OpenSessionInView的问题
- 写文章
- JAVA EE 5 的发展史
- C# 操作 app.config
- SQL优化(二)
- Summary on 20080701: insert value for identity column in sql
- 掌握 Ajax,第 2 部分: 使用 JavaScript 和 Ajax 发出异步请求
- 你会用英语点餐吗
- SQL优化(三)
- 代码阅读日志1
- Excel导入数据库,代码实现。
- 在EXCEL中如何使用VBA进行格式转化
- 《肥仔C日记》导言
- JAVA链接Mysql数据库