2015年7月16日 星期四

SQL 取得identity資訊

目前想試寫一個排程同步的軟體
預到的第一步就是identity問題
找了一下網路如可簡單組出已下
select 
IDENT_SEED('table_name') as 起始值,
IDENT_INCR('table_name') as 每次增值, 
IDENT_CURRENT('table_name') as 目前最大值  
重置indentity
dbcc checkident('table_name', RESEED, 100) 
Insert後取得indentity
Select @@Identity
參考來源
請問要去那個資料表查出自動編號 IDENTITY (x,y ) 的起始值(x)及增量
SQL Server的Identity字段使用/复制/重设
Usage of IDENT_INCR and IDENT_SEED function of Identity column in sql server