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.
Author |
Topic |
noblemfd
Starting Member
38 Posts |
Posted - 2014-04-09 : 19:15:00
|
How do I auto number in stored procedure (spCustomer) from this table. It will auto-generate CustID and CustCodeCREATE TABLE tblCustomer(CustID BIGINT NOT NULL PRIMARY KEY,CustCode NVARCHAR(10) NOT NULL,CustName NVARCHAR(100) NOT NULL,CustPhone NVARCHAR(15) NULL)CustID | CustCode | CustName | CustPhone1 |Cust-00001 | Adeleye | 080557662 |Cust-00002 | Oluseyi | 080886643 |Cust-00003 | Obafemi | 08066666 |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2014-04-09 : 19:16:47
|
Use the IDENTITY option for the column and then use SCOPE_IDENTITY() after the insert.Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|