Home > Database > Mysql Tutorial > SQLServer2005 Output子句获取刚插入的ID值

SQLServer2005 Output子句获取刚插入的ID值

WBOY
Release: 2016-06-07 18:04:36
Original
1071 people have browsed it

SQLServer2005的Output子句获取刚插入的ID值

语法很简单,比如

代码如下:
declare @t table (id uniqueidentifier default newid (), name varchar (100 ))
insert into @t (name ) output inserted .id select 'jinjazz' union select 'sqlserver'


/*输出类似
3880DB77-5ADF-472D-A68D-7518DD76F3B8
F478A3F5-A501-404E-A328-372EEC26279D
*/

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template