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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 unique identity problem

Author  Topic 

shahzebkn
Starting Member

4 Posts

Posted - 2007-04-11 : 16:01:05
Hi

I have mysql query I converted it into sqlserver 2000 query. But it give me error....

--------------------------------------------------------
CREATE TABLE `newsletterarchive` (
`id` int(5) NOT NULL auto_increment,
`title` text NOT NULL,
`dateadded` varchar(255) NOT NULL default '',
`body` longtext NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`)
)
--------------------------------------------------------

I converted it for sqlserver 2000 like this..

--------------------------------------------------------
CREATE TABLE newsletterarchive (
id int NOT NULL IDENTITY,
title varchar(100) NOT NULL,
dateadded varchar(255) NOT NULL default '',
body varchar(200) NOT NULL,
PRIMARY KEY (id),
-- UNIQUE KEY id (id)
)
--------------------------------------------------------

But it give me error here is here....

Server: Msg 156, Level 15, State 1, Line 7
Incorrect syntax near the keyword 'KEY'.

Anyone could help me.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-04-11 : 16:15:31
CREATE TABLE newsletterarchive (
id int IDENTITY(1, 1) PRIMARY KEY,
title varchar(100) NOT NULL,
dateadded varchar(255) NOT NULL default '',
body varchar(200) NOT NULL
)


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

shahzebkn
Starting Member

4 Posts

Posted - 2007-04-11 : 16:20:37
Thanks for your help what about unique key. Or there isn't unique key concept in sqlserver.

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-04-11 : 16:25:36
Yes, there is. You can lookup "CREATE TABLE" in Books Online and study the examples.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -