Exams Attended

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

MSSQL Interview Questions and Answers

Ques 1. What is the simplest way to create a new database in MS SQL Server?

The simplest way to create a new database is to use the "CREATE DATABASE" statement with this syntax:

CREATE DATABASE database_name

For example, run this statement:

CREATE DATABASE YourDataBaseName
GO

A new database called "YourDataBaseName" should be created in the SQL server. Of course, YourDataBaseName database should be empty at this moment - no tables. But it should have some other data objects automatically created by the server.

Is it helpful? Add Comment View Comments
 

Ques 2. How to set the current database in MS SQL Server?

Once you are connected to the SQL Server, you should select a database to work with and set it as the current database using the "USE" statement with this syntax:

USE database_name

The following tutorial example shows you how to set "YourDataBaseName" as the current database, and create a table in "YourDataBaseName":

USE YourDataBaseName
GO
Changed database context to 'YourDataBaseName'.

CREATE TABLE Links (Name NVARCHAR(32))
GO

SELECT name, type_desc, create_date FROM sys.tables
GO
name type_desc create_date
Links USER_TABLE 2007-05-19 23:05:43.700

Is it helpful? Add Comment View Comments
 

Ques 3. How to delete a database in MS SQL Server?

If you created a database incorrectly, or you have a database that is not needed any more, you can delete it with the "DROP DATABASE" statement with this syntax:

DROP DATABASE database_name

For example, execute this statement:

DROP DATABASE YourDataBaseName
GO

The database "YourDataBaseName" created in the previous tutorial should be deleted from the SQL server.

Warning, if you delete a database, all tables and their data in that database will be deleted.

Is it helpful? Add Comment View Comments
 

Ques 4. Why I am getting this error when dropping a database in MS SQL Server?

If you are trying to drop a database that is in use, you will get an error message like this: 'Cannot drop database "withoutbook" because it is currently in use.'

Before dropping a database, you must stop all client sessions using this database. If your own client session is using this database, you should set a different database as the current database as shown in this tutorial example:

CREATE DATABASE withoutbook
GO

USE withoutbook
GO

DROP DATABASE withoutbook
GO
Msg 3702, Level 16, State 4, Server LOCALHOSTSQLEXPRESS
Cannot drop database "withoutbook" because it is
currently in use.

USE master
GO

DROP DATABASE withoutbook
GO

Is it helpful? Add Comment View Comments
 

Ques 5. What is Microsoft SQL Server?

Microsoft SQL Server is a relational database management system (RDBMS) developed by Microsoft. It runs on Windows systems and uses Transact-SQL as the query language.

Microsoft SQL Server release history:

* 1993 - SQL Server 4.21 for Windows NT
* 1995 - SQL Server 6.0, codenamed SQL95
* 1996 - SQL Server 6.5, codenamed Hydra
* 1999 - SQL Server 7.0, codenamed Sphinx
* 1999 - SQL Server 7.0 OLAP, codenamed Plato
* 2000 - SQL Server 2000 32-bit, codenamed Shiloh (version 8.0)
* 2003 - SQL Server 2000 64-bit, codenamed Liberty
* 2005 - SQL Server 2005, codenamed Yukon (version 9.0)
* 2005 - SQL Server 2005 Express Edition, restricted free version

Is it helpful? Add Comment View Comments
 

Most helpful rated by users:

©2021 WithoutBook