在insert資料時取得序號欄位值(臨時資料表)



drop table if exists #test_t

create table #test_t (
  sn bigint,
  sid nvarchar(50),
  no nvarchar(50),
  name nvarchar(50)
)

insert into test(sid, no, name) output inserted.sn, inserted.sid, inserted.no, inserted.name into #test_t values('123','1','2')
insert into test(sid, no, name) output inserted.sn, inserted.sid, inserted.no, inserted.name into #test_t values('222','1','2')

select * from #test_t

select * from test





留言

這個網誌中的熱門文章

SQL設定SQL Server最大連線數及查詢語句

[MS-SQL] 利用資料庫的 Database mail 功能發送郵件 - 3.Send mail test

[MS-SQL]一些抓取資料庫結構及述敍用的 SQL