Assignment Module-5&6
Assignment Module-5&6
1) ----- Create a stored procedure to display the restaurant name, type and
cuisine where the table booking is not zero
exec usp_SPJomato
2) ----- Create a transaction and update the cuisine type ‘Cafe’ to ‘Cafeteria’.
Check the result and rollback it.
begin transaction
rollback transaction
3) ----- Generate a row number column and find the top 5 areas with the highest
rating of restaurants.
with top_areas
as
(
select restaurantname, area, localaddress, rating, ROW_NUMBER() over(partition by
area order by rating desc) as rows
from jomato)
------------------or---------------------
With RestaurantRank
as
(
Select RestaurantName, area, Rating, ROW_NUMBER() Over(Order by Rating Desc) as
RowNum From Jomato)
------------or------------
select top 5
DENSE_RANK () over(order by rating desc) as Rownum, RestaurantName, area, rating
from Jomato
4) ----- Use the while loop to display the 1 to 50.
begin
print(@count)
set @count = @count+1
end
5) ------ Write a query to Create a Top rating view to store the generated top 5
highest rating of restaurants.
------or---------
----------or----------
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'New_Name',
@recipients = @email_id,
@subject = @subject,
@body = @body
end
end
-------------or------------
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'New_name',
@recipients = '[email protected]',
@subject = 'New Record Inserted.',
@body = 'A new record has been inserted.'
end