SQL Questions

Q:

What are defaults? Is there a column to which a default can’t be bound?

Answer

A default is a value which will be used by a column, if no value is supplied to that column while inserting data.


Yes, IDENTITY and TIMESTAMP columns are free from the bounds of default.

Report Error

View answer Workspace Report Error Discuss

Subject: SQL

0 2602
Q:

What is Analysis service repository?

Answer

Every Analysis server has a repository to store metadata for the objects like cubes, data sources etc. It’s by default stored in a MS Access database which can be also migrated to a SQL Server database.

Report Error

View answer Workspace Report Error Discuss

Subject: SQL

0 2561
Q:

Where SQL server user names and passwords are stored in SQL server?

Answer

They get stored in System Catalog Views sys.server_principals and sys.sql_logins.

Report Error

View answer Workspace Report Error Discuss

Subject: SQL

0 2558
Q:

Define a temp table.

Answer

In a nutshell, a temp table is a temporary storage structure. It means you can use a temp table to store data temporarily so you can manipulate and change it before it reaches its destination format.


In table_user.gender column change ‘male to female’ and ‘female to male’ in one SQL statement.


UPDATE table_user


SET gender =


CASE gender


WHEN ‘male’ THEN ‘female’


WHEN ‘female’ THEN ‘male’


ELSE gender


END

Report Error

View answer Workspace Report Error Discuss

Subject: SQL

1 2534
Q:

Explain the use of keyword WITH ENCRYPTION. Create a Store Procedure with Encryption

Answer

It is a way to convert the original text of the stored procedure into encrypted form. The stored procedure gets obfuscated and the output of this is not visible to


CREATE PROCEDURE Abc


WITH ENCRYPTION


AS


<< SELECT statement>>


GO

Report Error

View answer Workspace Report Error Discuss

Subject: SQL

0 2522
Q:

What is SQL Server Agent?

Answer

SQL Server agent plays an important role in the day-to-day tasks of a database administrator (DBA). Its purpose is to ease the implementation of tasks for the DBA, with its full- function scheduling engine, which allows you to schedule your own jobs and scripts.

Report Error

View answer Workspace Report Error Discuss

Subject: SQL

0 2465
Q:

What is difference between DELETE and TRUNCATE commands?

Answer

Delete command removes the rows from a table based on the condition that we provide with a WHERE clause. Truncate will actually remove all the rows from a table and there will be no data in the table after we run the truncate command.


TRUNCATE:


- TRUNCATE is faster and uses fewer system and transaction log resources than DELETE.


- TRUNCATE removes the data by deallocating the data pages used to store the table's data, and only the page deallocations are recorded in the transaction log.


- TRUNCATE removes all rows from a table, but the table structure, its columns, constraints, indexes and so on, remains. The counter used by an identity for new rows is reset to the seed for the column.


- You cannot use TRUNCATE TABLE on a table referenced by a FOREIGN KEY constraint. Because TRUNCATE TABLE is not logged, it cannot activate a trigger.


- TRUNCATE cannot be rolled back.


- TRUNCATE is DDL Command.


- TRUNCATE Resets identity of the table


DELETE:


- DELETE removes rows one at a time and records an entry in the transaction log for each deleted row.


- If you want to retain the identity counter, use DELETE instead. If you want to remove table definition and its data, use the DROP TABLE statement.


- DELETE Can be used with or without a WHERE clause


- DELETE Activates Triggers.


- DELETE can be rolled back.


- DELETE is DML Command.


- DELETE does not reset identity of the table.


Note: DELETE and TRUNCATE both can be rolled back when surrounded by TRANSACTION if the current session is not closed. If TRUNCATE is written in Query Editor surrounded by TRANSACTION and if session is closed, it can not be rolled back but DELETE can be rolled back.

Report Error

View answer Workspace Report Error Discuss

Subject: SQL

0 2455
Q:

When do you use UPDATE_STATISTICS command?

Answer

This command is used when a large processing of data has occurred. If any large amount of deletions, any modifications, or Bulk Copy into the tables has occurred, it has to update the indexes to take these changes into account. UPDATE_STATISTICS updates the indexes on these tables accordingly.


 

Report Error

View answer Workspace Report Error Discuss

Subject: SQL

0 2371