reseed auto_increment to specific number?

The name of the pictureThe name of the pictureThe name of the pictureClash 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










share|improve this question























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
















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










share|improve this question























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












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










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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
















  • @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










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






share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "182"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    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






























    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






    share|improve this answer
























      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






      share|improve this answer






















        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






        share|improve this answer












        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







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 1 hour ago









        Randi Vertongen

        2665




        2665



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            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













































































            Comments

            Popular posts from this blog

            White Anglo-Saxon Protestant

            Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

            One-line joke