Question:- What is AUTO_INCREMENT?
Answer:- AUTO_INCREMENT is used in SQL to automatically generate a unique number whenever a new record is inserted into a table. Since the primary key is unique for each record, this primary field is added as the AUTO_INCREMENT field so that it is incremented when a new record is inserted. The AUTO-INCREMENT value starts from 1 and is incremented by 1 whenever a new record is inserted. Syntax: CREATE TABLE Employee( Employee_id int NOT NULL AUTO-INCREMENT, Employee_name varchar(255) NOT NULL, Employee_designation varchar(255) Age int, PRIMARY KEY (Employee_id) )
Question:- What is the difference between DELETE and TRUNCATE commands?
Answer:- • DELETE: This query is used to delete or remove one or more existing tables. • TRUNCATE: This statement deletes all the data from inside a table. The difference between DELETE and TRUNCATE commands are as follows: • TRUNCATE is a DDL command, and DELETE is a DML command. • With TRUNCATE, we cannot really execute and trigger, while with DELETE, we can accomplish a trigger. • If a table is referenced by foreign key constraints, then TRUNCATE will not work. So, if we have a foreign key, then we have to use the DELETE command. The syntax for the DELETE command: DELETE FROM table_name [WHERE condition]; Example: select * from stu delete from stu where s_name=’Bob’ The syntax for the TRUNCATE command: TRUNCATE TABLE Table_name; Example: select * from stu1 truncate table stu1 This deletes all the records from a table.
Question:- What is the difference between DROP and TRUNCATE commands?
Answer:- If a table is dropped, all things associated with that table are dropped as well. This includes the relationships defined on the table with other tables, access privileges, and grants that the table has, as well as the integrity checks and constraints. To create and use the table again in its original form, all the elements associated with the table need to be redefined. However, if a table is truncated, there are no such problems as mentioned above. The table retains its original structure.
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.
