Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 4th, 2012  |  syntax: None  |  size: 0.36 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Auto-Index generation in C# .Net by coding
  2. CREATE TABLE [dbo].[Foo](
  3.     [Foo] [int] IDENTITY(1,1) NOT NULL,
  4.     //Other columns
  5. )
  6.        
  7. ALTER TABLE [dbo].[Foo](
  8.     [Foo] [int] IDENTITY(<Enter your last maximum number in the database>,1) NOT NULL,
  9.     //Other columns
  10. )
  11.        
  12. Select Max(Key Field) + 1 from [table name]//this will give you new key value i.e. 12