GO
/****** Object: UserDefinedFunction [dbo].[Format_Number_Zero]
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- select [dbo].[Format_Number_Zero](4,'0000')
-- ket qua la 0004
CREATE FUNCTION [dbo].[Format_Number_Zero]
(
-- Add the parameters for the function here
@so int
, @format nvarchar(20)
)
RETURNS nvarchar(20)
AS
BEGIN
DECLARE @KQ nvarchar(20)
-- Declare the return variable here
SELECT @KQ=RIGHT(@format + CAST(@so as varchar), LEN(@format))
RETURN @KQ
END
Hàm tạo số 0 theo định dạng