Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SELECT MAX(VAL(id))+1 AS id FROM stock INTO DBF temp\newid

Status
Not open for further replies.

madurrani

Programmer
Sep 23, 2008
7
Example item list: 1100A, 1110U, 1112I

In foxpro & Visual Foxpro I used to issue following command to get new item id.

SELECT MAX(VAL(id))+1 AS id FROM stock INTO DBF temp\newid

How can i use this command in VB.NET/SQL

Thanks,

Aamir Durrani
 
Code:
SELECT [NewID] = MAX([id])+1 FROM Stock
If possible, i would steer away from using keywords as field, table, database names. Instead of id, I would use something like StockID. You can then give it an Identity Seed and it will increment the value for you when an INSERT is done. Placing the INSERT into a Stored Procedure, you can have the Stored Proc return the new ID for further references in your program.

"...and did we give up when the Germans bombed Pearl Harbor? NO!"
"Don't stop him. He's roll'n.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top