Groups | Blog | Home
all groups > sql server new users > february 2007 >

sql server new users : Create table error


Gail Erickson [MS]
2/19/2007 9:05:15 AM
Hi Zoë,

"unsigned" is not a recognized keyword in SQL Server and the equivalent to
auto_increment is IDENTITY
With these two small changes, you're good to go.
create table department (dept_id smallint not null IDENTITY(1,1),

name varchar(20) not null, constraint pk_department primary key (dept_id))

See these Books Online topics.

http://msdn2.microsoft.com/en-us/library/ms187745.aspx for integer data
type details
http://msdn2.microsoft.com/en-us/library/ms186775.aspx for the IDENTITY
property
and
http://msdn2.microsoft.com/en-us/library/ms174979.aspx for CREATE TABLE
syntax

--
Gail Erickson [MS]
SQL Server Documentation Team
This posting is provided "AS IS" with no warranties, and confers no rights
Download the latest version of Books Online from
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx


[quoted text, click to view]

Gail Erickson [MS]
2/19/2007 12:14:59 PM
Glad to hear the topics were useful. I encourage you to download the latest
version of Books Online (
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx).
It's big and it can be difficult to find things (especially, when you're not
sure what to look for) but it does cover the SQL Server product end-to-end.

--
Gail Erickson [MS]
SQL Server Documentation Team
This posting is provided "AS IS" with no warranties, and confers no rights
Download the latest version of Books Online from
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
'
[quoted text, click to view]

Zoë Braven-Giles
2/19/2007 4:22:37 PM
Hi

Working with SQL Server 2005

I am trying to create a table with the following code

create table department
(dept_id smallint unsigned not null auto_increment,
name varchar(20) not null,
constraint pk_department primary key (dept_id)
)

but keep coming up with an error. I suspect that I am trying to use mysql
(which I don't want to use!) instead of sql, but can't find the changes I
need to make.

Thank you in advance

Zoë Braven-Giles
2/19/2007 5:17:22 PM
Fantastic Gail. Thank you, just what I was looking for.

The books I bought which said that they taught SQL turn out to only teach
MySQL. It's very frustrating.

[quoted text, click to view]

AddThis Social Bookmark Button