SQL Server output子句用法 output inserted.id 获取刚插入数据的id
2016-04-07 21:45
661 查看
--插入数据,并返回刚刚插入的数据id
INSERT INTO [soloreztest] ([name]) output inserted.id VALUES ('solorez')
--执行结果:
--id
-------------
--5
(1 行受影响)
第二种方法:
insert into table1 values(colvalue1,colvalue2)
select ident_current('table1')
第三种方法:
insert into table1 values(colvalue1,colvalue2)
select @@identity
INSERT INTO [soloreztest] ([name]) output inserted.id VALUES ('solorez')
--执行结果:
--id
-------------
--5
(1 行受影响)
第二种方法:
insert into table1 values(colvalue1,colvalue2)
select ident_current('table1')
第三种方法:
insert into table1 values(colvalue1,colvalue2)
select @@identity
相关文章推荐
- PL/SQL Developer 的 SQL 编辑窗口显示行号
- PL/SQL Developer 中文字段显示乱码
- mysqldump: Got error: 1: Can't create/write to file '/data/export/test.txt' (Errcode: 13)
- PL/SQL Developer连接Oracle数据库
- 使用mysqldump备份数据库时报Got error: 2013错误
- MYSQL报错 error: Got a packet bigger than ‘max_allowed_packet’ bytes
- ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables opt
- oracle中的sql%rowcount,sql%found、sql%notfound、sql%rowcount和sql%isopen
- SQL Server 2005登录名,用户名,角色,架构之间的关系
- django 直接执行SQL
- dango mysql 的问题
- mysql状态查看 QPS/TPS/缓存命中率查看
- PL/SQL Developer如何连接64位的Oracle图解
- 错误:‘bOS::SQL::SQLCommand::SQLOperation’既不是类也不是命名空间
- MySQL性能监控指标查询
- (五)PLSQL Developer 配置监听
- MySQL常用维护命令和操作
- Sql Server数据库之通过SqlBulkCopy快速插入大量数据
- MyBatis输出sql需要log4j.properties配置
- MySQL Optimization