Can someone please help me with a DECLARE, SET, PRINT in sql server. my issue is variable 3 does not add up to 99999.99? I am so frustrated
CHAPTER 14 - USING VARIABLES IN SCRIPTS ---
Use the AP database.
Create 3 variables named anything you want.
Set the first variable equal to 9876.22.
Set the second variable equal to 187.69.
Set the third variable equal to the sum of the first and second
variables.
Use a PRINT statement to print "The value of variable 3 is:
99999.99, where 99999.99 is the value of the variable 3.
DECLARE @Variable1 as decimal(10,2), @Variable2
decimal(10,2)
DECLARE @Variable3 varchar(20)
SET @Variable1 = 9876.22
SET @Variable2 = 187.69
SET @Variable3 = SUM(@Variable1 + @Variable2)
PRINT CONVERT(DECIMAL(10,2), @VARIABLE1)
PRINT CONVERT(DECIMAL(10,2), @VARIABLE2)
PRINT CONVERT(DECIMAL(10,2), @VARIABLE3)
Need to change the variable1 and variable2 value to get the output 99999.99 of variable3
CREATE PROCEDURE ADDNUMBER
AS
DECLARE @Variable1 as decimal(10,2), @Variable2 decimal(10,2)
--declare variable1,variable2
DECLARE @Variable3 varchar(20) --declare variable3
SET @Variable1 = 9876.22 --assign the value to variable1
SET @Variable2 = 90123.77 --assign the value to variable2
--SET @Variable1 = 9876.22 --assign the value to variable1
--SET @Variable2 = 187.69 --assign the value to
variable2
SET @Variable3 = SUM(@Variable1 + @Variable2) --add the variable1 and variable2 and assign the value to variable3
PRINT CONVERT(DECIMAL(10,2), @VARIABLE1) --print variable1
PRINT CONVERT(DECIMAL(10,2), @VARIABLE2) --print variable2
PRINT CONVERT(DECIMAL(10,2), @VARIABLE3) --print variable3
output:
create a procedure select the code and press execute button to create a procedure
Now write EXECUTE ADDNUMBER to execute the procedure
Can someone please help me with a DECLARE, SET, PRINT in sql server. my issue is variable 3 does not add up to 99999.99? I am so frustrated CHAPTER 14 - USING VARIABLES IN SCRIPTS --- Use the AP datab...