Question: write an sql query for the following questions 4. Write a script that uses two variables to store (1) the count of all of the

write an sql query for the following questions

4. Write a script that uses two variables to store (1) the count of all of the instructors in the Instructors table and (2) the average annual salary for those instructors. If the instructors annual salary is less than or equal to 4000, the script should provide a bonus of 10% of the salary and then displays the bonus. Otherwise, the script should print a message that says, No bonus. 5. Write a script that attempts to delete the department with the name Sociology from the departments table. If the delete is successful, the script should display this message: SUCCESS: The record was deleted. If the delete is unsuccessful, the script should display a message something like this: FAILURE: The record was not deleted. Error 547: The DELETE statement conflicted with the REFERENCE constraint "FK Instructo Depar 267ABA7A". The conflict occurred in the database "College", table "dbo. Instructors", column 'DepartmentID'. 6. Write a script that determines which departments are offering less than three courses and more than 5 courses. To do this, you can use a cursor. When you loop through the rows in the cursor, the script should display a message like this: 7 courses are offered in department 1 2 courses are offered in department 5 2 courses are offered in department 7 PART B: USE SQLCMD to complete the following questions. 1. Write the TSQL code to print the instructor id, and the full name of those teaching the course Anatomy.Use the Table variable to print the results. Sample output: 2. Create a local temporary table with the following fields(id, name), 3. Then insert a row into it and display the results. Open ssms and retrieve the rows from the temporary table you created. Did you get the results? If not explain what happened. 4. Create the vendorcopy table from vendors. Use OBJECT_ID to delete the vendorcopy table and use DB_ID to check the database college available in database engine or not.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!