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
Thulasiram pakala
911
872
115.5k
Increment not working in stored procedure
Mar 30 2017 2:48 AM
i am using this sp i need to increment 010000 after that 010001 like that but it will not increment
ALTER procedure [dbo].[Sales_Recept]
as
begin
(SELECT BILLNO =
CASE
WHEN COUNT(bill_of_sale) = 0 THEN '000001'
WHEN Len(Max(CONVERT(int, Substring(bill_of_sale,1,6)))) = 1 AND Max(CONVERT(int, Substring(bill_of_sale,1,6))) < 9 THEN '00000' + Convert(Varchar(6),(Max(CONVERT(int, Substring(bill_of_sale,1,6)))) + 1)
WHEN Len(Max(CONVERT(int, Substring(bill_of_sale,1,6)))) = 1 AND Max(CONVERT(int, Substring(bill_of_sale,1,6))) = 9 THEN '0000' + Convert(Varchar(6),(Max(CONVERT(int, Substring(bill_of_sale,1,6)))) + 1)
WHEN Len(Max(CONVERT(int, Substring(bill_of_sale,1,6)))) = 2 AND Max(CONVERT(int, Substring(bill_of_sale,1,6))) < 99 THEN '0000' + Convert(Varchar(6),(Max(CONVERT(int, Substring(bill_of_sale,1,6)))) + 1)
WHEN Len(Max(CONVERT(int, Substring(bill_of_sale,1,6)))) = 2 AND Max(CONVERT(int, Substring(bill_of_sale,1,6))) = 99 THEN '000' + Convert(Varchar(6),(Max(CONVERT(int, Substring(bill_of_sale,1,6)))) + 1)
WHEN Len(Max(CONVERT(int, Substring(bill_of_sale,1,6)))) = 3 AND Max(CONVERT(int, Substring(bill_of_sale,1,6))) < 999 THEN '000' + Convert(Varchar(6),(Max(CONVERT(int, Substring(bill_of_sale,1,6)))) + 1)
WHEN Len(Max(CONVERT(int, Substring(bill_of_sale,1,6)))) = 3 AND Max(CONVERT(int, Substring(bill_of_sale,1,6))) = 999 THEN '00' + Convert(Varchar(6),(Max(CONVERT(int, Substring(bill_of_sale,1,6)))) + 1)
WHEN Len(Max(CONVERT(int, Substring(bill_of_sale,1,6)))) = 4 AND Max(CONVERT(int, Substring(bill_of_sale,1,6))) < 9999 THEN '00' + Convert(Varchar(6),(Max(CONVERT(int, Substring(bill_of_sale,1,6)))) + 1)
WHEN Len(Max(CONVERT(int, Substring(bill_of_sale,1,6)))) = 4 AND Max(CONVERT(int, Substring(bill_of_sale,1,6))) > 9999 THEN '0' + Convert(Varchar(6),(Max(CONVERT(int, Substring(bill_of_sale,1,6)))) + 1)
END
FROM Sales_details)
end
Reply
Answers (
2
)
Crm post and pre images entity
How to NUNIT test a MVC application?