1
0
mirror of https://github.com/alex-bochkov/ssms-addin.git synced 2025-11-23 22:04:53 +02:00
Files
ssms-addin/QueryTemplates/Common Scripts/copy-identity-values.sql

15 lines
475 B
MySQL
Raw Normal View History

2017-09-11 07:52:50 -07:00
sp_msforeachdb N'
USE [?];
PRINT ''USE [?]'';
With AllIdent as (SELECT
CAST(last_value as bigint) + 1 as NextValue, OBJECT_NAME(T.object_id) as TName, SCHEMA_NAME(T.schema_id) as SName
FROM sys.identity_columns IC
inner join sys.tables T on IC.object_id = T.object_id
where last_value is not null
)
select
''DBCC CHECKIDENT ('' + QUOTENAME(SName +''.''+ TName, '''''''') + '', RESEED, '' + CAST(NextValue as VARCHAR(15))+ ''); ''
FROM AllIdent
where DB_ID() > 4
'