答案 0 :(得分:-1)
DECLARE @Dividend INT ,@ Dividend1 INT ,@ Dividend2 INT ,@ Dividend3 INT ,@ Dividend4 INT ,@ Dividend5 INT ,@ Dividend6 INT ,@ Dividend7 INT ,@ Dividend8 INT ,@ Dividend9 INT ,@ Dividend10 INT ,@ Dividend11 INT ,@ Dividend12 INT ,@ Dividend13 INT ,@ Dividend14 INT ,@ Dividend15 INT ,@ Dividend16 INT ,@ Divisor INT ,@ Quotient INT ,@ Remainder INT ,@ EmployeeID BIGINT ,@ EmployeeName VARCHAR(200) ,@ Quotient1000 BIGINT ,@ Quotient500 BIGINT ,@ Quotient100 BIGINT ,@ Quotient50 BIGINT ,@ Quotient20 BIGINT ,@ Quotient10 BIGINT ,@ Quotient5 BIGINT ,@ Quotient2 BIGINT ,@ Quotient1 BIGINT
- 从SALARYGEN1中选择EmployeeID,EmployeeName SET @EmployeeID =( SELECT EmployeeID 来自SALARYGEN1 ) SET @EmployeeName =( SELECT EmployeeName 来自SALARYGEN1 ) SET @Dividend =( 选择NetsaLARY 来自SALARYGEN1 WHERE EmployeeID = @EmployeeID )
IF(@Dividend> = 1000) 开始 IF(@Dividend> = 1000) 开始 - 插入sa164值(@Number) --SET @Dividend = 40 SET @Divisor = 1000
SELECT @Quotient1000 = @Dividend / @Divisor
---ationhist values(@Quotient)
PRINT 'Value of Quotient1000= ' + convert(VARCHAR, @Quotient1000)
--insert into dec(EmployeeId,EmployeeName,Quotient1000) values(@EmployeeID,@EmployeeName,@Quotient)
SELECT @Remainder = @Dividend % @Divisor
SET @Dividend2 = @Remainder
END
ELSE
BEGIN
SET @Dividend2 = @Remainder
SET @Quotient1000 = 0
PRINT 'Value of Quotient1000= ' + convert(VARCHAR, @Quotient)
END
IF (@Dividend2 >= 500)
BEGIN
SET @Divisor = 500
SELECT @Quotient500 = @Dividend2 / @Divisor
SELECT @Remainder = @Dividend2 % @Divisor
SET @Dividend3 = @Remainder
PRINT 'Value of Quotient500= ' + convert(VARCHAR, @Quotient500)
--insert into dec(EmployeeId,EmployeeName,Quotient500) values(@EmployeeID,@EmployeeName,@Quotient)
--PRINT 'Value of Remainder= ' + convert(varchar,@Remainder)
--PRINT 'The number is small.';
END
ELSE
BEGIN
SET @Dividend3 = @Remainder
SET @Quotient500 = 0
--set @Quotient=0
PRINT 'Value of Quotient500= ' + convert(VARCHAR, @Quotient)
END
IF (@Dividend3 >= 100)
BEGIN
SET @Divisor = 100
SELECT @Quotient100 = @Dividend3 / @Divisor
SELECT @Remainder = @Dividend3 % @Divisor
SET @Dividend4 = @Remainder
PRINT 'Value of Quotient100= ' + convert(VARCHAR, @Quotient100)
--PRINT 'Value of Remainder= ' + convert(varchar,@Remainder)
--PRINT 'The number is small.';
END
ELSE
BEGIN
SET @Dividend4 = @Remainder
SET @Quotient100 = 0
--set @Quotient=0
PRINT 'Value of Quotient100= ' + convert(VARCHAR, @Quotient)
END
IF (@Dividend4 >= 50)
BEGIN
SET @Divisor = 50
SELECT @Quotient50 = @Dividend4 / @Divisor
SELECT @Remainder = @Dividend4 % @Divisor
SET @Dividend5 = @Remainder
PRINT 'Value of Quotient50= ' + convert(VARCHAR, @Quotient50)
-- PRINT 'Value of Remainder= ' + convert(varchar,@Remainder)
--PRINT 'The number is small.';
END
ELSE
BEGIN
SET @Dividend5 = @Remainder
SET @Quotient50 = 0
--set @Quotient=0
PRINT 'Value of Quotient50= ' + convert(VARCHAR, @Quotient)
END
IF (@Dividend5 >= 20)
BEGIN
SET @Divisor = 20
SELECT @Quotient20 = @Dividend5 / @Divisor
SELECT @Remainder = @Dividend5 % @Divisor
SET @Dividend6 = @Remainder
PRINT 'Value of Quotient20= ' + convert(VARCHAR, @Quotient20)
-- PRINT 'Value of Remainder= ' + convert(varchar,@Remainder)
--PRINT 'The number is small.';
END
ELSE
BEGIN
SET @Dividend6 = @Remainder
SET @Quotient20 = 0
--set @Quotient=0
PRINT 'Value of Quotient20= ' + convert(VARCHAR, @Quotient)
END
IF (@Dividend6 >= 10)
BEGIN
SET @Divisor = 10
SELECT @Quotient10 = @Dividend6 / @Divisor
SELECT @Remainder = @Dividend6 % @Divisor
SET @Dividend7 = @Remainder
PRINT 'Value of Quotient10= ' + convert(VARCHAR, @Quotient10)
-- PRINT 'Value of Remainder= ' + convert(varchar,@@Dividend10)
--PRINT 'The number is small.';
END
ELSE
BEGIN
SET @Dividend7 = @Remainder
SET @Quotient10 = 0
--set @Quotient=0
PRINT 'Value of Quotient10= ' + convert(VARCHAR, @Quotient)
END
IF (@Dividend7 >= 5)
BEGIN
SET @Divisor = 5
SELECT @Quotient5 = @Dividend7 / @Divisor
SELECT @Remainder = @Dividend7 % @Divisor
SET @Dividend8 = @Remainder
--SET @Dividend13=@Dividend10
PRINT 'Value of Quotien5= ' + convert(VARCHAR, @Quotient5)
-- PRINT 'Value of Remainder= ' + convert(varchar,@@Dividend10)
--PRINT 'The number is small.';
END
ELSE
BEGIN
SET @Dividend8 = @Remainder
SET @Quotient5 = 0
--set @Quotient=0
PRINT 'Value of Quotient5= ' + convert(VARCHAR, @Quotient)
END
IF (@Dividend8 >= 2)
BEGIN
SET @Divisor = 2
SELECT @Quotient2 = @Dividend8 / @Divisor
SELECT @Remainder = @Dividend8 % @Divisor
SET @Dividend9 = @Remainder
--SET @Dividend13=@Dividend10
PRINT 'Value of Quotien2= ' + convert(VARCHAR, @Quotient2)
-- PRINT 'Value of Remainder= ' + convert(varchar,@@Dividend10)
--PRINT 'The number is small.';
END
ELSE
BEGIN
--/--SET @Dividend15 = @Remainder
SET @Quotient2 = 0
SET @Dividend9 = @Remainder
--set @Quotient=0
PRINT 'Value of Quotient2= ' + convert(VARCHAR, @Quotient)
END
IF (@Dividend9 >= 1)
BEGIN
SET @Divisor = 1
SELECT @Quotient1 = @Dividend9 / @Divisor
SELECT @Remainder = @Dividend9 % @Divisor
PRINT 'Value of Quotien1= ' + convert(VARCHAR, @Quotient1)
-- PRINT 'Value of Remainder= ' + convert(varchar,@@Dividend10)
--PRINT 'The number is small.';
END
ELSE
BEGIN
SET @Dividend10 = @Remainder
SET @Quotient1 = 0
--set @Quotient=0
PRINT 'Value of Quotient1= ' + convert(VARCHAR, @Quotient)
END
INSERT INTO DEC(EmployeeID, EmployeeName, Quotient1000, Quotient500, Quotient100, Quotient50, Quotient20, Quotient10, Quotient5, Quotient2, Quotient1,Activeflag,Createeddate)
VALUES (
@EmployeeID
,@EmployeeName
,@Quotient1000
,@Quotient500
,@Quotient100
,@Quotient50
,@Quotient20
,@Quotient10
,@Quotient5
,@Quotient2
,@Quotient1
,1
,GETDATE()
)
END 其他 IF(@Dividend> = 500) 开始 IF(@Dividend> = 500) 开始 - 插入sa164值(@Number) --SET @Dividend = 40 SET @Divisor = 500
SELECT @Quotient = @Dividend / @Divisor
--insert into denomationhist values(@Quotient)
PRINT 'Value of Quotient500= ' + convert(VARCHAR, @Quotient)
SELECT @Remainder = @Dividend % @Divisor
SET @Dividend2 = @Remainder
END
ELSE
BEGIN
SET @Dividend2 = @Remainder
SET @Quotient = 0
PRINT 'Value of Quotient500= ' + convert(VARCHAR, @Quotient)
END
IF (@Dividend2 >= 100)
BEGIN
SET @Divisor = 100
SELECT @Quotient = @Dividend2 / @Divisor
SELECT @Remainder = @Dividend2 % @Divisor
SET @Dividend3 = @Remainder
PRINT 'Value of Quotient100= ' + convert(VARCHAR, @Quotient)
--PRINT 'Value of Remainder= ' + convert(varchar,@Remainder)
--PRINT 'The number is small.';
END
ELSE
BEGIN
SET @Dividend3 = @Remainder
SET @Quotient = 0
--set @Quotient=0
PRINT 'Value of Quotient100= ' + convert(VARCHAR, @Quotient)
END
IF (@Dividend3 >= 50)
BEGIN
SET @Divisor = 50
SELECT @Quotient = @Dividend3 / @Divisor
SELECT @Remainder = @Dividend3 % @Divisor
SET @Dividend4 = @Remainder
PRINT 'Value of Quotient50= ' + convert(VARCHAR, @Quotient)
--PRINT 'Value of Remainder= ' + convert(varchar,@Remainder)
--PRINT 'The number is small.';
END
ELSE
BEGIN
SET @Dividend4 = @Remainder
SET @Quotient = 0
--set @Quotient=0
PRINT 'Value of Quotient50= ' + convert(VARCHAR, @Quotient)
END
IF (@Dividend4 >= 20)
BEGIN
SET @Divisor = 20
SELECT @Quotient = @Dividend4 / @Divisor
SELECT @Remainder = @Dividend4 % @Divisor
SET @Dividend5 = @Remainder
PRINT 'Value of Quotient20= ' + convert(VARCHAR, @Quotient)
-- PRINT 'Value of Remainder= ' + convert(varchar,@Remainder)
--PRINT 'The number is small.';
END
ELSE
BEGIN
SET @Dividend5 = @Remainder
SET @Quotient = 0
--set @Quotient=0
PRINT 'Value of Quotient20= ' + convert(VARCHAR, @Quotient)
END
IF (@Dividend5 >= 10)
BEGIN
SET @Divisor = 10
SELECT @Quotient = @Dividend5 / @Divisor
SELECT @Remainder = @Dividend5 % @Divisor
SET @Dividend6 = @Remainder
PRINT 'Value of Quotient10= ' + convert(VARCHAR, @Quotient)
-- PRINT 'Value of Remainder= ' + convert(varchar,@Remainder)
--PRINT 'The number is small.';
END
ELSE
BEGIN
SET @Dividend6 = @Remainder
SET @Quotient = 0
--set @Quotient=0
PRINT 'Value of Quotient10= ' + convert(VARCHAR, @Quotient)
END
IF (@Dividend6 >= 5)
BEGIN
SET @Divisor = 5
SELECT @Quotient = @Dividend6 / @Divisor
SELECT @Remainder = @Dividend6 % @Divisor
SET @Dividend7 = @Remainder
PRINT 'Value of Quotient5= ' + convert(VARCHAR, @Quotient)
-- PRINT 'Value of Remainder= ' + convert(varchar,@@Dividend10)
--PRINT 'The number is small.';
END
ELSE
BEGIN
SET @Dividend7 = @Remainder
SET @Quotient = 0
--set @Quotient=0
PRINT 'Value of Quotient5= ' + convert(VARCHAR, @Quotient)
END
IF (@Dividend7 >= 2)
BEGIN
SET @Divisor = 2
SELECT @Quotient = @Dividend7 / @Divisor
SELECT @Remainder = @Dividend7 % @Divisor
SET @Dividend8 = @Remainder
--SET @Dividend13=@Dividend10
PRINT 'Value of Quotien2= ' + convert(VARCHAR, @Quotient)
-- PRINT 'Value of Remainder= ' + convert(varchar,@@Dividend10)
--PRINT 'The number is small.';
END
ELSE
BEGIN
SET @Dividend8 = @Remainder
SET @Quotient = 0
--set @Quotient=0
PRINT 'Value of Quotient2= ' + convert(VARCHAR, @Quotient)
END
IF (@Dividend8 >= 1)
BEGIN
SET @Divisor = 1
SELECT @Quotient = @Dividend8 / @Divisor
SELECT @Remainder = @Dividend8 % @Divisor
SET @Dividend9 = @Remainder
--SET @Dividend13=@Dividend10
PRINT 'Value of Quotien1= ' + convert(VARCHAR, @Quotient)
-- PRINT 'Value of Remainder= ' + convert(varchar,@@Dividend10)
--PRINT 'The number is small.';
END
ELSE
BEGIN
--/--SET @Dividend15 = @Remainder
SET @Quotient = 0
SET @Dividend9 = @Remainder
--set @Quotient=0
PRINT 'Value of Quotient1= ' + convert(VARCHAR, @Quotient)
END
IF (@Dividend9 >= 1)
BEGIN
SET @Divisor = 1
SELECT @Quotient = @Dividend9 / @Divisor
SELECT @Remainder = @Dividend9 % @Divisor
PRINT 'Value of Quotien1= ' + convert(VARCHAR, @Quotient)
-- PRINT 'Value of Remainder= ' + convert(varchar,@@Dividend10)
--PRINT 'The number is small.';
END
ELSE
BEGIN
SET @Dividend10 = @Remainder
SET @Quotient = 0
--set @Quotient=0
PRINT 'Value of Quotient1= ' + convert(VARCHAR, @Quotient)
END
END