Table MyTable with Id as an IDENTITY column (auto insert records)
CREATE TABLE [dbo].[MyTable] ( [Id] int IDENTITY(1, 1) NOT NULL, [Component] varchar(50));
A Sample procedure that inserts a record and returns the id of the record inserted
CREATE PROCEDURE [dbo].[InsertRetId] @Component [VARCHAR](50), @Id int output AS BEGIN INSERT INTO [dbo].[MyTable] ([Component] VALUES (@Component); select @Id = Scope_Identity(); END
No comments:
Post a Comment