Question

Can anyone please help me with these SQL Server Questions? I am using SQL Server 2008...

Can anyone please help me with these SQL Server Questions? I am using SQL Server 2008

1. Write the code to create two table with at least 10 fields of various data types.

2. Write the code to insert 20 rows of data into the table that you created.

3. Write the code – “Select” statements to write three different reports from your data.

4. Write the code to create a report that incorporates functions.

5. Write the code to create two different views from the data that you created.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

This demonstration is using SQL Server.Database and tables are created using SQL Server Management Studio (SSMS).

Database :

/*create database TrainingDB*/
create database TrainingDB;

/*use TrainingDB to create table*/
use TrainingDB;

Tables :

1.Table Name :Trainers

SQL Query :

/*1.Table Name : Trainers*/
Create table Trainers(
TrainerID int primary key,
TrainerName varchar(50) not null,
Experience decimal(4,2) not null check (Experience > 2),
skills varchar(100) not null,
address text
);

/*Inserting records into Trainers*/
insert into Trainers values(1,'Virat Kohli',3,'Cricket coaching','Pune');
insert into Trainers values(2,'Sachin Tendulkar',18,'Cricket coaching','Mumbai');
insert into Trainers values(3,'Mahesh Sabnis',18,'Angular 7','Chennai');
insert into Trainers values(4,'Ajinkya Rahane',5.6,'MongoDB','Hyderabad');
insert into Trainers values(5,'KL Rahul',2.2,'Responsive web Design','Bangluru');
insert into Trainers values(6,'Sanju Samson',2.2,'Node.js','Kochi');
insert into Trainers values(7,'Eoan Morgan',7.7,'Node with ExpressJS','Jaipur');
insert into Trainers values(8,'Hardik Pandey',4.4,'Full Stack','Badoda');
insert into Trainers values(9,'KP',2.1,'Mean Stack','Delhi');
insert into Trainers values(10,'Rahul Dravid',15.1,'DBA','Kolkatta');

/*selecting records*/
select * from Trainers;

Screen in SSMS:

*********************************

2.Table Name :

SQL Query :

/*2.Table Name :ClientTrainings*/
create table ClientTrainings (
TrainingsID int ,
TrainingName varchar(100) not null ,
TrainerID int not null,
Client varchar(20) not null,
IsAvailable char(4) not null,
TrainingDate date,
primary key (TrainingsID),
foreign key (TrainerID) references Trainers(TrainerID)
);


/*insert records into Trainings table*/
insert into ClientTrainings values (1,'Getting Started with Angular 7',3,'Microsoft USA','Yes','12/05/2019');
insert into ClientTrainings values (2,'Cricket Speech',2,'NCA Bangluru','No','01/05/2019');
insert into ClientTrainings values (3,'Angualr 5',2,'NCA Bangluru','Yes','05/05/2019');
insert into ClientTrainings values (4,'JavaScript Basics',1,'NCA Bangluru','NO','02/10/2018');
insert into ClientTrainings values (5,'MongoDB',1,'Fujitsu Pune','Yes','03/11/2018');
insert into ClientTrainings values (6,'Mean Stack',9,'HCL Chennai','NO','02/12/2017');
insert into ClientTrainings values (7,'Docker Contrainer',10,'JP Mogran Mumbai','Yes','04/02/2019');
insert into ClientTrainings values (8,'.NET',7,'Sama Software Nashik','Yes','06/06/2019');
insert into ClientTrainings values (9,'Database',8,'SKS Software Pune','Yes','02/10/2018');
insert into ClientTrainings values (10,'Full stack Development',1,'C2L Solutions','Yes','07/07/2019');

/*selecting records*/
select * from ClientTrainings;

Screen in SSMS:

*********************************

Question 3.

SQL Query :

/*SQL Query that returns TrainingName 'Angualr 7','Cricket Speech' */
select Trainers.TrainerID,TrainerName,Experience,TrainingName
from Trainers,ClientTrainings where Trainers.TrainerID=ClientTrainings.TrainerID
order by Trainers.TrainerID

Screen in SSMS :

*********************************

Question 3.2:

SQL Query :

/*SQL Query that returns Trainer Id, Trainer Name , Trainings Name for given date */
select Trainers.TrainerID,TrainerName,TrainingName,TrainingDate
from trainers, Clienttrainings
where
trainers.trainerID=Clienttrainings.TrainerID and
TrainingDate='05/05/2019';

Screen in SSMS :

*******************************

Select all records from ClientTrainings table:

select * from clientTrainings;

Screen in SSMS :

******************************

Question 4 :

SQL Query :

/*create function to get Trainners details*/
create function getTrainderDetails()
returns table
as
return (select * from Trainers)

/*call function*/
select * from getTrainderDetails();

Screen in SSMS :

*******************************

Question 5 :

SQL Query :

--!create view to get all available trainers id
create view availableTrainer
as
select TrainerID from ClientTrainings where IsAvailable='Yes'

--execute view
select * from availableTrainer;

Screen in SSMS :

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.

Add a comment
Know the answer?
Add Answer to:
Can anyone please help me with these SQL Server Questions? I am using SQL Server 2008...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Complete the following using Microsoft® SQL Server® 2016: Write SQL scripts in Microsoft® SQL Server® for...

    Complete the following using Microsoft® SQL Server® 2016: Write SQL scripts in Microsoft® SQL Server® for OLTP that include: A Data Definition Language (DDL) script creating the four tables with appropriate data types, primary and foreign keys Data Manipulation Language (DML) scripts that insert a minimum of five records into each table Select scripts showing the full contents of each table Write and run a test script for Step Two. Save a screenshot of the results. Create a 6-page Technical...

  • Python Question. I am trying to connect to a database and create a table using Python...

    Python Question. I am trying to connect to a database and create a table using Python in this code but I keep getting an error on line 48 saying that "Quotes" is not defined. Could anyone please help me set this up correctly? I am using Azure SQL Database to create this. import pyodbc import json import requests as r import pprint connection_string = 'Driver={ODBC Driver 17 for SQL Server};' \ 'Server=randomquotegenerator.database.windows.net,1433;' \ 'Database=RandomQuoteGenerator;' \ 'Uid=carterholliday;' \ 'Pwd=MIS54002k19;' \ 'TrustServerCertificate=no;'...

  • I am using Oracle SQL Live so please write the SQL Query in the format that...

    I am using Oracle SQL Live so please write the SQL Query in the format that Oracle SQL Live can run I need to create a trigger that will update the Product QoH when a new product is purchased. (A new product is purchased when a row is added to the line table). I have linked the code of the script since it exceed Chegg’s Character Limit: https://docs.google.com/document/d/1HbHnMrk6Qw99B72kpDyYCFibUJVsYEi-6RKDsmb3fg4/edit?usp=sharing

  • I am supposed to create the code in SQL for the 3 Triggers using the information...

    I am supposed to create the code in SQL for the 3 Triggers using the information on the table below. 13.. Assume the Branch table contains a column called ?Total value that-represents the -total price. for all books.at -that branch. Following ?the style shown in-the text, write the code for the following-triggers. a.-When ?inserting a row in the Copy table, -add -the price -to the -total -value for the appropriate branch . b. When-updating -a -row in-the Copy table, .add-the-difference...

  • Please access to TUN SQL/Assistant using the default database = db_pvfc12_std 1.- Run a query to...

    Please access to TUN SQL/Assistant using the default database = db_pvfc12_std 1.- Run a query to retrieve all the data field from db_pvfc12_std in table CUSTOMER_T 2.- Run a query to retrieve record --> CustomerID = 11, How many records did you get and why? 3.- Run a query to retrieve all the data field from table Order_T               Once retrieved:                              3.1.- Please name the fields showing: Primary Key, Foreign Key and other fields                              3.2.- What type of...

  • Can anyone teach me what codes should I use in this question please? The datafile hotdogs.csv...

    Can anyone teach me what codes should I use in this question please? The datafile hotdogs.csv in the Data folder on Avenue gives the measured number of calories and amount of sodium (in mg) for hotdogs from 54 major brands. The data were measured in a laboratory for a Consumer Reports article on the nutritional value of a hotdog. Three types of hotdog were examined, all-beef, poultry or meat (mainly pork and beef but with up to 15% poultry). Use...

  • 1.Write a pl/SQL block that selects all the rows from the A2order table and prints them...

    1.Write a pl/SQL block that selects all the rows from the A2order table and prints them to screen. THIS CAN BE EASILY DONE USING AGGREGATE FUNCTIONS, BUT YOU MUST NOT USE AGGREGATE FUNCTIONS IN THIS ASSIGNMENT 2. 2.Write a pl/sql block that deletes the orders from the A2order table that were ordered after the order that has the highest order_price (Order_date will tell you when a row was entered). YOU MUST USE BULK OPERATIONS FOR THIS CODE 3. Write a...

  • Using MySQL commands answer the questions listed below using the Premier Products Company schema. 1.Using Views...

    Using MySQL commands answer the questions listed below using the Premier Products Company schema. 1.Using Views a) Create a view called part_location that has the following attributes: part_num, part_description, part_quantity, warehouse_name, warehouse_address. This data comes from the part and warehouse entities. b) Write a query using the view that shows the total number of parts ordered from each warehouse. The output should look like this: 2. Using Triggers a) Execute the following SQL to create the customer_audit table in the...

  • this is about databases and SQL, please help me with this and i promise i will...

    this is about databases and SQL, please help me with this and i promise i will thumbs you up :) let me know if you need more info please try to get this done i will definitely thumbs you up :)) PROJECT TOPIC: Library: Books, Copies of the books, Patrons, Checkouts when creating ERD diagram, the notation must be in crows notation, attached at the bottom is an example of crows foot notation in databases so you can understand. PDF...

  • this is about databases and SQL, please help me with this and i promise i will...

    this is about databases and SQL, please help me with this and i promise i will thumbs you up :) let me know if you need more info please try to get this done i will definitely thumbs you up :)) PROJECT TOPIC: Library: Books, Copies of the books, Patrons, Checkouts when creating ERD diagram, the notation must be in crows notation, attached at the bottom is an example of crows foot notation in databases so you can understand. PDF...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT