139k views
1 vote
MSSQL

Create sp_Q2 as a stored procedure, which takes no input but it performs the tasks
in the order listed below:
(1) sp_Q2 first finds the country of suppliers who supply products with the top 2
highest unit price. It does not matter if these two products belong to the same
supplier or not. Also, it does not matter if the supplier of these two products
are in the same country or not.
(2) sp_Q2 does not return the countries, instead, it calls sp_Q1 (completed
in Q1) using the countries it finds.

Like in Q1, you should include 'go' to indicate the end of script that creates the
procedure and include a testing script to test sp_Q2.

The hint below is just a hint. You don't have to use it if you have a better approach.

Hint: save the countries in a table of any type (e.g., table variable, temporary table,
or using 'select...into') and retrieve one country a time into a variable.

1 Answer

7 votes

Answer:

The code is given below

{

string cipher = "";

//Where cipher is an algorithm used.

for (int y = 0; iy< msg.length(); i++)

{

if(msg[i]!=' ')

/* applying encryption formula ( c x + d ) mod m

{here x is msg[i] and m is 26} and added 'A' to

bring it in range of ascii alphabet[ 65-90 | A-Z ] */

cipher = cipher +

(char) ((((a * (msg[i]-'A') ) + b) % 26) + 'A');

else

cipher += msg[i];

}

return cipher;

}

User James Hiew
by
5.3k points