TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mayooran Navamany
324
5.6k
133.1k
auto_increment code stored procedures sql server
Jul 21 2016 6:38 AM
this code work but auto_increment not work what is the right code.. correct me
ALTER PROCEDURE [dbo].[GRNInfo]
@GrnCode nchar(10) ,
@ItemCode nchar(10) ,
@Qty int ,
@TotalPrice decimal(18, 0) ,
@GrnDate date
AS
BEGIN
DECLARE @Max INT
if not exists (select GrnCode from atoGRN where GrnCode=@GrnCode)
begin
------------------------------------------------------------------------------------------------------------------
--SET @GrnCode = 'GRN00001'
SELECT @Max = CONVERT(INT, SUBSTRING(CONVERT(VARCHAR(10),@GrnCode), 3, 10)++1) FROM atoGRN
SET @GrnCode = 'GRN' + RIGHT('0000' + CONVERT(VARCHAR(10),@Max ++ 1 ) , 5)
----------------------------------------------------------------------------------------------------------
insert into atoGRN (GrnCode,FK_ItemCode,Qty,TotalPrice,GrnDate) values (@GrnCode,@ItemCode,@Qty,@TotalPrice,@GrnDate)
end
Reply
Answers (
2
)
How to create ledger in c# windows Apllication
Parent & Child Forms