Question:- What is a “TRIGGER” in SQL?
Answer:- The trigger can be defined as an automatic process that happens when an event occurs in the database server. It helps to maintain the integrity of the table. The trigger is activated when the commands, such as insert, update, and delete, are given. The syntax used to generate the trigger function is: CREATE TRIGGER trigger_name
Question:- Where are usernames and passwords stored in SQL Server?
Answer:- In SQL Server, usernames and passwords are stored in the main database in the sysxlogins table.
Question:- What are the types of relationships in SQL Server databases?
Answer:- Relationships are developed by interlinking the column of one table with the column of another table. There are three different types of relationships, which are as follows: • One-to-one relationship • Many-to-one relationship • Many-to-many relationship
Question:- What are the third-party tools that are used in SQL Server?
Answer:- The following is the list of third-party tools that are used in SQL Server: • SQL CHECK • SQL DOC 2 • SQL Backup 5 • SQL Prompt • Litespeed 5.0
Question:- How can you handle expectations in SQL Server?
Answer:- TRY and CATCH blocks handle exceptions in SQL Server. Put the SQL statement in the TRY block and write the code in the CATCH block to handle expectations. If there is an error in the code in the TRY block, then the control will automatically move to that CATCH block.
Question:- How many authentication modes are there in SQL Server? And what are they?
Answer:- Two authentication modes are available in SQL Server. They are: • Windows Authentication Mode: It allows authentication for Windows but not for SQL Server. • Mixed Mode: It allows both types of authentication—Windows and SQL Server.
Question:- What is a function in SQL Server?
Answer:- A function is an SQL Server database object. It is basically a set of SQL statements that allow input parameters, perform processing, and return results only. A function can only return a single value or table; the ability to insert, update, and delete records in database tables is not available.
Question:- Mention different types of replication in SQL Server?
Answer:- In SQL Server, three different types of replications are available: • Snapshot replication • Transactional replication • Merge replication
Question:- What is the COALESCE function?
Answer:- The COALESCE function takes a set of inputs and returns the first non-null value. Syntax: COALESCE(val1,val2,val3,……,nth val) Example: SELECT COALESCE(NULL, 1, 2, ‘MYSQL’) Output: 1
Question:- Can we link SQL Server with others?
Answer:- SQL Server allows the OLEDB provider, which provides the link, to connect to all databases. Example: Oracle, I have an OLEDB provider that has a link to connect with an SQL Server group.
Question:- SQL Server allows the OLEDB provider, which provides the link, to connect to all databases. Example: Oracle, I have an OLEDB provider that has a link to connect with an SQL Server group.
Answer:- SQL Server Agent plays an important role in the daily work of SQL Server administrators or DBAs. This is one of the important parts of SQL Server. The aim of the server agent is to easily implement tasks using a scheduler engine that enables the tasks to be performed at scheduled times. SQL Server Agent uses SQL Server to store scheduled management task information.
Question:- What do you know about magic tables in SQL Server?
Answer:- A magic table can be defined as a provisional logical table that is developed by an SQL Server for tasks such as insert, delete, or update (DML) operations. The operations recently performed on the rows are automatically stored in magic tables. Magic tables are not physical tables; they are just temporary internal tables.
Question:- What are some common clauses used with SELECT queries in SQL?
Answer:- There are many SELECT statement clauses in SQL. Some of the most commonly used clauses with SELECT queries are: • FROM The FROM clause defines the tables and views from which data can be interpreted. The tables and views listed must exist at the time the question is given. • WHERE The WHERE clause defines the parameters that are used to limit the contents of the results table. You can test for basic relationships or for relationships between a column and a series of columns using subselects. • GROUP BY The GROUP BY clause is commonly used for aggregate functions to produce a single outcome row for each set of unique values in a set of columns or expressions. • ORDER BY The ORDER BY clause helps in choosing the columns on which the table’s result should be sorted. • HAVING The HAVING clause filters the results of the GROUP BY clause by using an aggregate function.
Question:- What is wrong with the following SQL query?
Answer:- SELECT gender, AVG(age) FROM employee WHERE AVG(age)>30 GROUP BY gender When this command is executed, it gives the following error: Msg 147, Level 16, State 1, Line 1 Aggregation may not appear in the WHERE clause unless it is in a subquery contained in the HAVING clause or a select list; the column being aggregated is an outer reference. Msg 147, Level 16, State 1, Line 1 Invalid column name ‘gender’. This basically means that whenever we are working with aggregate functions and are using the GROUP BY clause, we cannot use the WHERE clause. Therefore, instead of the WHERE clause, we should use the HAVING clause. When we are using the HAVING clause, the GROUP BY clause should come first, followed by the HAVING clause. select e_gender, avg(e_age) from employee group by e_gender having avg(e_age)>30
