hello,

I'm trying to create a database in SQL Server management Studio for a project. I have created a tabel named Employee and I have 14 columns. I need to set the firts column (Emp_ID) as Primary Key (accomplished) and then generate a unique number for each Emp_ID that I insert. currently I have no information in my database I'm stuck in finding the procedure to correctly code the SQL statement that will generate a unique Emp_ID when I insert new values or add a new row of information. Can someone please help? I"ve look all over my text and searched the web and cannot find something useful to help.

thanks in advance

Recommended Answers

All 2 Replies

CREATE TABLE Employee
(
Emp_Id int PRIMARY KEY IDENTITY,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255),
postalcode vachar(6),
/* other columns*/
)

not sure about sql server, identity SHOULD be the keyword to make it autoincrement

Thank you very much for your help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.