sql server output用法说明
带有output的insert语句.
@@identity只能返回当前会话最后生产的标识列. 如果一次性插入多条语句的话. 需要返回这些自动生产的标识列. 那么outpu就派上用场了.
declare @temp table(k int, v nvarchar(200))
insert into t1(datacol)
output inserted.keycol, inserted.datacol
into @temp
select * from @temp --------------------
insert into DownLog
output
newid(),inserted.id,inserted.ID,inserted.ID, inserted.ID,getdate() into MatchOrderLog
values('123444','aaaaaa.txt',getdate(),1,1,1)
select * from MatchOrderLog
带有output的delete语句和update语句也大同小异.
delete语句能操作deleted临时表. 而update的本质是delete和insert一次能操作inserted和updated两张表.
update loanee set MatchOrder=@MatchOrder,UpdateTime=getdate()
output
newid(),deleted.id,deleted.ApplicationID,deleted.MatchOrder, inserted.MatchOrder,getdate() into MatchOrderLog
where ApplicationID=@ApplicationID and DeleteState=0 and LoaneeType=0
============================
deleted.参数名 是更改前的参数值
inserted.参数名 是更改或者插入后的参数值
使用 格式 : insert into 表名 output inserted.参数名,inserted.参数名2 into 记录表 values(表值,表值2,表值3...)
update 表名 set 参数名=参数值,参数名2=参数值2 ... output inserted.参数名,inserted.参数名2 into 记录表 where 条件...
sql server output用法说明的更多相关文章
- SQL Server特殊用法笔记
1. MERGE用法:关联两表,有则改,无则加 SQL语句: create table #AAA(id int,A int,AA int,AAA int,B int) create table #BB ...
- SQL SERVER各种用法总结
sql创建临时表http://www.cnblogs.com/jeffwongishandsome/archive/2009/08/05/1526466.html sqlserver更改表名 EXEC ...
- SQL Server output子句用法 output inserted.id 获取刚插入数据的id
--插入数据,并返回刚刚插入的数据id INSERT INTO [soloreztest] ([name]) output inserted.id VALUES ('solorez') --执行结果: ...
- SQL Server存储过程用法介绍
存储过程其实就是已预编译为可执行过程的一个或多个SQL语句. 通过调用和传递参数即可完成该存储过程的功能. 前面有介绍过存储过程的一些语法,但是没有详细示例,今天我们来一起研究一下存储过程. 提高性能 ...
- SQL Server output经典使用
output经典使用 分类: sql2012-02-16 18:17 409人阅读 评论(0) 收藏 举报 outputinserttabledeletegonull OUTPUT是SQL SERVE ...
- SQL Server @@ERROR 用法
@@error是系统函数,当没有发生错误时返回0,如果发生错误时@@error<>0,并返回错误号,每个SQL语句执行完,@@error值都会变. @@error只记录当前错误,如果存储过 ...
- SQL server 常见用法记录
-- ============================================= -- Author: tanghong -- Create da ...
- VBA 连接sql server的用法
cnnstr = "Provider=sqloledb;Data Source=192.211.21.8;Initial Catalog=pub;UID=账号;PWD=密码" VB ...
- SQL Server merge用法
有两个表名:source 表和 target 表,并且要根据 source 表中匹配的值更新 target 表. 有三种情况: source 表有一些 target 表不存在的行.在这种情况下,需要将 ...
随机推荐
- php--列表展示(小实训一月考)
效果图:
- iOS视图控制对象生命周期
iOS视图控制对象生命周期-init.viewDidLoad.viewWillAppear.viewDidAppear.viewWillDisappear.viewDidDisappear的区别及用途 ...
- 【C++】函数指针宏定义
看耗子叔文章学习虚函数表(http://blog.csdn.net/haoel/article/details/1948051)的时候被例子的第一句惊到了 typedef void(*Fun)(voi ...
- JS的基础类型与引用类型
两种类型: ECMAScript变量包含两种不同类型的值:基本类型值.引用类型值: 基本类型值:指的是保存在栈内存中的简单数据段: 引用类型值:指的是那些保存在堆内存中的对象,意思是,变量中保存的实际 ...
- imx6 KEY_ROW4 power output high fail
imx6 KEY_ROW4的pin设置成gpio之后,不能够输出高电平.解决方法记录于此. 参考链接: https://lists.yoctoproject.org/pipermail/meta-fr ...
- synchronized锁自旋
http://www.jianshu.com/p/5dbb07c8d5d5 原理 通常说的synchronized在方法或块上加锁,这里的锁就是对象锁(当然也可以在类上面),或者叫重量锁,在JVM中又 ...
- In App Purchase Statuses
In App Purchase StatusesThe following are the available states that can be assigned to your in app p ...
- ionic 白名单
1.在本目录下执行 cordova plugin add cordova-plugin-whitelist 2.在config.xml里添加 <allow-navigation href=&qu ...
- Android图片压缩方法总结
本文总结Android应用开发中三种常见的图片压缩方法,分别是:质量压缩法.比例压缩法(根据路径获取图片并压缩)和比例压缩法(根据Bitmap图片压缩). 第一:质量压缩方法: ? 1 2 3 ...
- andriod网址
http://www.runoob.com/w3cnote/android-tutorial-end.html 入门教程 长青说安卓