0

Hi i'm new to sql server here i have sql query to alter the table like

ALTER TABLE `ct_email_templates`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=30;

How can i write this query into sql server?

I tried the below one, is this correct or not?

ALTER TABLE ct_email_templates
add id int IDENTITY(1,30) NOT NULL

Please help me. Thanks in advance.

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
user3668438
  • 165
  • 5
  • 18
  • 1
    I'm not sure on what `AUTO_INCREMENT=30` does, but if this means that every row added the number should be raised by 30, then in Sql server that's the second parameter of the `Identity` - meaning it should be `IDENTITY(1, 30)`. – Zohar Peled Mar 16 '17 at 14:25
  • Possible duplicate of [Adding an identity to an existing column](http://stackoverflow.com/questions/1049210/adding-an-identity-to-an-existing-column) – DhruvJoshi Mar 16 '17 at 14:26
  • modified check it once@zoharPeled – user3668438 Mar 16 '17 at 14:50

1 Answers1

0

as per this AUTO_INCREMENT=30 ensures your next value is 31

so your current query should be like below

ALTER TABLE ct_email_templates
add id int IDENTITY(30,1) NOT NULL

this tells SQLServer to start your identity values from 30

Community
  • 1
  • 1
TheGameiswar
  • 27,855
  • 8
  • 56
  • 94