reseed auto_increment to specific number?

Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
1
down vote
favorite
Is it possible to set the identity column of a table to start from a specific value?
I'm converting an ETL stage from mysql to a sql server database where a staging database loads records with a unique ID starting from the maximum value in the main database (which is not auto-incrementing). The mysql went like this:
SET @s = Concat('alter table table_1 auto_increment=',coalesce(@indexmaxt,0)+1);
Ideally this is what I want to do:
DBCC CHECKIDENT (table_1 , RESEED, @indexmaxt+1)
Is this possible or is this impossible in SQL server
sql-server mysql etl auto-increment
add a comment |Â
up vote
1
down vote
favorite
Is it possible to set the identity column of a table to start from a specific value?
I'm converting an ETL stage from mysql to a sql server database where a staging database loads records with a unique ID starting from the maximum value in the main database (which is not auto-incrementing). The mysql went like this:
SET @s = Concat('alter table table_1 auto_increment=',coalesce(@indexmaxt,0)+1);
Ideally this is what I want to do:
DBCC CHECKIDENT (table_1 , RESEED, @indexmaxt+1)
Is this possible or is this impossible in SQL server
sql-server mysql etl auto-increment
@Akina Sorry I realised I forgot to mention that I'm doing this in a sql server database
â Exostrike
1 hour ago
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Is it possible to set the identity column of a table to start from a specific value?
I'm converting an ETL stage from mysql to a sql server database where a staging database loads records with a unique ID starting from the maximum value in the main database (which is not auto-incrementing). The mysql went like this:
SET @s = Concat('alter table table_1 auto_increment=',coalesce(@indexmaxt,0)+1);
Ideally this is what I want to do:
DBCC CHECKIDENT (table_1 , RESEED, @indexmaxt+1)
Is this possible or is this impossible in SQL server
sql-server mysql etl auto-increment
Is it possible to set the identity column of a table to start from a specific value?
I'm converting an ETL stage from mysql to a sql server database where a staging database loads records with a unique ID starting from the maximum value in the main database (which is not auto-incrementing). The mysql went like this:
SET @s = Concat('alter table table_1 auto_increment=',coalesce(@indexmaxt,0)+1);
Ideally this is what I want to do:
DBCC CHECKIDENT (table_1 , RESEED, @indexmaxt+1)
Is this possible or is this impossible in SQL server
sql-server mysql etl auto-increment
sql-server mysql etl auto-increment
edited 1 hour ago
asked 1 hour ago
Exostrike
286
286
@Akina Sorry I realised I forgot to mention that I'm doing this in a sql server database
â Exostrike
1 hour ago
add a comment |Â
@Akina Sorry I realised I forgot to mention that I'm doing this in a sql server database
â Exostrike
1 hour ago
@Akina Sorry I realised I forgot to mention that I'm doing this in a sql server database
â Exostrike
1 hour ago
@Akina Sorry I realised I forgot to mention that I'm doing this in a sql server database
â Exostrike
1 hour ago
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
This works, does that answer your question?
create table dbo.test (id int identity(1,1), value int);
declare @indexmaxt int = 9999,@indexmaxt2 int;
SET @indexmaxt2 = @indexmaxt+1;
DBCC CHECKIDENT ('dbo.test' , RESEED, @indexmaxt2);
insert into dbo.test(value) values(1);
select * from dbo.test;
Results:
id 10000
value
1
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
This works, does that answer your question?
create table dbo.test (id int identity(1,1), value int);
declare @indexmaxt int = 9999,@indexmaxt2 int;
SET @indexmaxt2 = @indexmaxt+1;
DBCC CHECKIDENT ('dbo.test' , RESEED, @indexmaxt2);
insert into dbo.test(value) values(1);
select * from dbo.test;
Results:
id 10000
value
1
add a comment |Â
up vote
2
down vote
accepted
This works, does that answer your question?
create table dbo.test (id int identity(1,1), value int);
declare @indexmaxt int = 9999,@indexmaxt2 int;
SET @indexmaxt2 = @indexmaxt+1;
DBCC CHECKIDENT ('dbo.test' , RESEED, @indexmaxt2);
insert into dbo.test(value) values(1);
select * from dbo.test;
Results:
id 10000
value
1
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
This works, does that answer your question?
create table dbo.test (id int identity(1,1), value int);
declare @indexmaxt int = 9999,@indexmaxt2 int;
SET @indexmaxt2 = @indexmaxt+1;
DBCC CHECKIDENT ('dbo.test' , RESEED, @indexmaxt2);
insert into dbo.test(value) values(1);
select * from dbo.test;
Results:
id 10000
value
1
This works, does that answer your question?
create table dbo.test (id int identity(1,1), value int);
declare @indexmaxt int = 9999,@indexmaxt2 int;
SET @indexmaxt2 = @indexmaxt+1;
DBCC CHECKIDENT ('dbo.test' , RESEED, @indexmaxt2);
insert into dbo.test(value) values(1);
select * from dbo.test;
Results:
id 10000
value
1
answered 1 hour ago
Randi Vertongen
2665
2665
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f219050%2freseed-auto-increment-to-specific-number%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password

@Akina Sorry I realised I forgot to mention that I'm doing this in a sql server database
â Exostrike
1 hour ago