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)
 AutogenerationNo

Author  Topic 

sureshkumar
Starting Member

11 Posts

Posted - 2004-08-15 : 09:33:56
Hi

I want to generate a autonumber in the employee table
eg :empcode varchar(50)
empcode : 000001

through stored procedure .

Any one please help me

Thanks and regards
suresh kumar.A

gpl
Posting Yak Master

195 Posts

Posted - 2004-08-15 : 11:27:03
why not use an identity and cast it to a varchar when you return it ?
Go to Top of Page

sureshkumar
Starting Member

11 Posts

Posted - 2004-08-15 : 12:23:12
Thanks

Now i made it as identity.whether can i display that number in the asp page while generate new record.
if possible how we can generate
Go to Top of Page

gpl
Posting Yak Master

195 Posts

Posted - 2004-08-15 : 14:28:59
You will need to return the newly generated Identity as an output param (@@Identity)

So the sequence goes something like this
user selects 'Enter a new record'
page is displayed
user fills in form
user presses submit
the form values are passed to a stored procedure that does the insert, immediately after the insert statement, Set your output parameter to @@Identity
return the output param to your asp, or return the whole record to your asp page in update mode

does this help ??

Graham
Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-08-15 : 18:09:16
INSERT table(field) VALUES('value') --If you have an identity column and a column called field.
SELECT SCOPE_IDENTITY() --You should use this instead of @@IDENTITY.

MeanOldDBA
derrickleggett@hotmail.com

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

sureshkumar
Starting Member

11 Posts

Posted - 2004-08-16 : 10:29:13
Thanks

Go to Top of Page
   

- Advertisement -