T-SQL procedure for MICROSOFT SQL SERVER A: obtain the name and credit limit of the customer whose number currently is stored in I_CUSTOMER_NUM. Place these values in the variables I_CUSTOMER_NAME and I_CREDIT_LIMIT, respectively. Output the content of I_CUSTOMER_NAME and I_CREDIT_LIMIT.
T-SQL procedure for MICROSOFT SQL SERVER
A: obtain the name and credit limit of the customer whose number currently is stored in I_CUSTOMER_NUM. Place these values in the variables I_CUSTOMER_NAME and I_CREDIT_LIMIT, respectively. Output the content of I_CUSTOMER_NAME and I_CREDIT_LIMIT.
HINT use cursor instructions as a template for the problem. Instructions goes as follows
CREATE PROCEDURE usp_DISP_REP_CUST
@repnum char(2)
AS
DECLARE@custnum char(3)
DECLARE@custname char(35)
DECLARE mycursor CURSOR READ_ONLY
FOR
SELECT CUSTOMER_NUM, CUSTOMER_NAME
FROM CUSTOMER
WHERE REP_NUM = @repnum
OPEN mycursor
FETCH NEXT FROM mycursor
INTO @custnum, @custname
WHILE @@FETCH_STATUS=0
BEGIN
PRINT@custnum+' '+@custname
FETCH NEXT FROM mycursor
INTO @custnum, @custname
END
CLOSE mycursor
DEALLOCATE mycursor
Step by step
Solved in 3 steps