Adding Sequence to a Table in SQL Server 2012 -


sorry asking kind of noob question , reading.

i need small clarification on adding sequence value column. if execute following code statement gets executed

create table execsqlorg_employee( emp_id int not null constraint df_emp_id default next value seq, emp_name varchar(100), emp_gender bit, emp_salary money, emp_shift bit) go 

or if define table first , execute alter command, statement gets executed

alter table exec_employee  add constraint df_app_id default next value seq app_id 

so far good!!

once if try add sequence columns following code error

create table execsqlorg_employee ( emp_id int not null constraint df_emp_id default next value seq, emp_name varchar(100), emp_gender bit, emp_salary money, emp_shift bit constraint pk_app_id primary key (emp_id), constraint df_app_id default next value seq emp_id   ) go 

when execute above code following error

incorrect syntax near 'for'.

just create table without sequence. , run query..

create sequence execsqlorg_employee.emp_id      start 1     increment 1 ; go 

to sequence default values..

create sequence execsqlorg_employee.emp_id  ; 

for more info... http://technet.microsoft.com/en-us/library/ff878091.aspx


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -