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
 SQL Server Development (2000)
 how to autogenerate id using a stored procedure

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-04-19 : 10:58:23
vikrant writes "i want to autogenerate the employee id while entering a new data in the database the user must not asked to enter the id every time a new record needs to be inserted as this employee id is also the primary field so this must be generated using a stored procedure.
i want the mechanism so that i can combine this stored procedure with my project in vb. its very urgent"

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2004-04-19 : 11:07:58
Have a look at IDENTITY....property of a column.
Search here (and BOL) for examples.
Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-04-20 : 07:53:40
You really do need to use the IDENTITY(1,1) option on the primary key column of your table if you are set on doing this. Generating the primary key from a stored procedure can cause lots of contention.

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

cas_o
Posting Yak Master

154 Posts

Posted - 2004-04-20 : 08:10:29
Contention?
how many people can you realistically hire/key in per second exactly?

;-]
Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-04-20 : 08:16:33
Well, I guess that depends on how big your company is and what kind of HR software your writing doesn't it. :)

If your company has 5 people, big deal. If this is an HR website and you are going to have hundreds of clients, or if your are part of a company with over 40,000 people like one I worked at for 5 years, it can be quite a lot.

It's just easier to design right then to redo it later. We're not talking about anything big here, right?

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

cas_o
Posting Yak Master

154 Posts

Posted - 2004-04-20 : 08:21:15
Well if you are hiring that many (40,000 in one day!!) or providing a service to many companies you're not gonna be running it on a single p4 are you?

;-]
Go to Top of Page

cas_o
Posting Yak Master

154 Posts

Posted - 2004-04-20 : 08:26:51
b4 this all gets outta hand, I'd use IDENTITY(1,1) too coz it's urgent and easy.

Don't want to take away what this forum is for which is helping the poor developer with the rapidly approaching deadline!

;-]
Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-04-20 : 09:06:15
I must have misread the original post and my replies. I believe we gave him advice, which was to put an IDENTITY(1,1) on his column. I don't see anywhere the original poster said he was running on a single p4. Did I just miss something here?????

We weren't "hiring" 40,000 people a day. We had more than 40,000 people working for the company. Our HR website could easily get several hundred hires and/or applications a day from the the call centers. We had over 20 of them.

Chill out. Have fun. Enjoy the weather man.

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page
   

- Advertisement -