Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL does not recognise keyword "identity"

Author  Topic 

seismology
Starting Member

2 Posts

Posted - 2009-08-23 : 18:40:52
I'm trying to create a new table with two columns, the first being a unique auto-incrementing identifier and primary key, the other being a string.

create table questions(ID int  primary key identity, string VARCHAR(100))


gives the following error message:

Error code 30000, SQL state 42X01: Syntax error: Encountered "identity" at line 1, column 44.
Line 1, column 1

Execution finished after 0 s, 1 error(s) occurred.


Removing the word "identity" removes the problem:

Executed successfully in 0.035 s, 0 rows affected.
Line 1, column 1

Execution finished after 0.035 s, 0 error(s) occurred.



Am I using the keyword "identity" correctly?

Thanks.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-08-23 : 18:53:51
the statement is fine in my MS SQL Server. Are you using MS SQL Server ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

seismology
Starting Member

2 Posts

Posted - 2009-08-23 : 19:17:08
I apologise, I seem to have asked on the wrong forums!

I'll ask elsewhere. Still, if you have any ideas I'd be grateful.

I'm using a local MySQL server embedded in a java application.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-08-23 : 19:20:08
sorry, i am not familiar with MySQL syntax. referring to the manual or post at dbforums.com


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-08-23 : 22:48:14
Not a MySQL expert, but I believe it goes like this:

id INTEGER AUTO_INCREMENT PRIMARY KEY 

http://dev.mysql.com/doc/refman/5.0/en/create-table.html
Go to Top of Page
   

- Advertisement -