CREATE FUNCTION [dbo].[GETBookingOrderNo]()
RETURNS CHAR(9)
AS
BEGIN
DECLARE @lastval NVARCHAR(50)
SET @lastval = (SELECT MAX(BookingOrderNo) FROM BookingDetailMaster)
IF @lastval IS NULL SET @lastval = 'RO 000001'
--SET @lastval='RO 000009'
DECLARE @i INT
SET @i = RIGHT(@lastval,6) + 1
RETURN 'RO ' + RIGHT('0000' + CONVERT(VARCHAR(10),@i),6)
END
GO
SELECT [dbo].[GETBookingOrderNo]()
RETURNS CHAR(9)
AS
BEGIN
DECLARE @lastval NVARCHAR(50)
SET @lastval = (SELECT MAX(BookingOrderNo) FROM BookingDetailMaster)
IF @lastval IS NULL SET @lastval = 'RO 000001'
--SET @lastval='RO 000009'
DECLARE @i INT
SET @i = RIGHT(@lastval,6) + 1
RETURN 'RO ' + RIGHT('0000' + CONVERT(VARCHAR(10),@i),6)
END
GO
SELECT [dbo].[GETBookingOrderNo]()