Question Bank / SQL Server


1.Microsoft SQL Server is
  • A.Non-relational database
  • B.Relational database
2.Syntax to create database "ShoppingCart"
  • A.Add Database ShoppingCart;
  • B.Create ShoppingCart Database;
  • C.Create Database ShoppingCart;
3.Syntax to rename database "ShoppingCart" to "ShoppingCartNew"
  • A.Alter Database ShoppingCart Rename Name =ShoppingCartNew;
  • B.Rename Database ShoppingCart Modify Name =ShoppingCartNew;
  • C.Alter Database ShoppingCart Modify Name =ShoppingCartNew;
  • D.Alter Database ShoppingCartNew;
4.Syntax to delete database "ShoppingCartNew"
  • A.Delete Database ShoppingCartNew;
  • B.Drop Database ShoppingCartNew;
  • C.Drop ShoppingCartNew Database;
5.Syntax to create table "UserInfo"
  • A.Add Table UserInfo
    (
      column1 datatype ...
    );
  • B.Create Table in <<Database_Name>> UserInfo
    (
      column1 datatype ...
    );
  • C.Create Table UserInfo
    (
      column1 datatype ...
    );
6.Syntax to add a new column "IsActive" char(1) in "UserInfo" table
  • A.Update Table UserInfo ADD IsActive Char(1);
  • B.ALTER Table UserInfo ADD IsActive Char(1);
  • C.Modify Table UserInfo ADD IsActive Char(1);
7.Syntax to Modify column "IsActive" data type from char(1) to bit in "UserInfo" table
  • A.Alter Table UserInfo Modify column IsActive bit;
  • B.ALTER Table UserInfo Add IsActive bit;
  • C.Alter Table UserInfo Alter column IsActive bit;
  • D.None of the above
8.Syntax to delete column "IsActive" in "UserInfo" table
  • A.Delete column IsActive in UserInfo;
  • B.Alter Table UserInfo Drop Column IsActive;
  • C.Drop Table UserInfo Alter IsActive;
  • D.All of the above
9.Syntax to rename column "IsActive" to "Status" in "UserInfo" table
  • A.Alter Table UserInfo Rename IsActive, 'Status';
  • B.EXEC sp_rename 'IsActive', Status, 'COLUMN';
  • C.EXEC sp_rename 'UserInfo.IsActive', Status, 'COLUMN';
10.Syntax to rename table "UserInfo" to "UserInformation"
  • A.EXEC rename_sp UserInfo, UserInformation;
  • B.EXEC sp_rename UserInfo, UserInformation;
  • C.Alter Table UserInfo Modify UserInformation;
11.Syntax to delete table "UserInformation"
  • A.Delete table UserInformation;
  • B.Drop UserInformation table;
  • C.Drop table UserInformation;
12.DML Stands for
  • A.Data Modification Language
  • B.Data Multiply Language
  • C.Data Manipulation Language
13.SQL Syntax to insert data into table "Customers" with columns CustomerId int and CustomerName varchar(250)
  • A.Insert Into Customers(CustomerId,CustomerName) values ('1',User Name);
  • B.Insert Into Customers(CustomerId,CustomerName) values ('1','User Name');
  • C.Insert Into Customers(CustomerId,CustomerName) values (1,'User Name');
  • D.Insert Customers(CustomerId,CustomerName) values (1,'User Name');
14.SQL Syntax to Select all columns from table "Customers" for a specific Customer with CustomerId 1
  • A.Select *,CustomerId,CustomerName From Customers Where CustomerId=1;
  • B.Select CustomerId From Customers Where CustomerId=1;
  • C.Select * From Customers;
  • D.Select * From Customers Where CustomerId=1;
15.SQL Syntax to update CustomerName of a specific Customer in table "Customers" for CustomerId 1
  • A.Update Customers Set CustomerName='User Name' And CustomerId=1;
  • B.Update Customers Set CustomerName='User Name' Where CustomerId=1;
  • C.Update Customers Set CustomerName='User Name', CustomerId=1;
  • D.Update Customers CustomerName='User Name' Where CustomerId=1;
16.SQL Syntax to delete a specific Customer from table "Customers" for CustomerId 1
  • A.Delete * From Customers Where CustomerId=1;
  • B.Delete From Customers;
  • C.Delete From Customers Where CustomerId=1;
  • D.Delete Customers Where CustomerId=1;
17.SQL Syntax to get Customers who's Age between 20 to 25 from table "Customers"
  • A.Select * From Customers Age Between 20 And 25;
  • B.Select * From Customers Where Age 20 And 25;
  • C.Select * From Customers Where Age Between 20 And 25;
18.SQL Syntax to get the total Customers Count from table "Customers"
  • A.Select * From Customers;
  • B.Select Count(*) From Customers;
  • C.Select MAX(*) From Customers;
  • D.Select MIN(*) From Customers;
19.SQL Syntax to get the Customers who's names start with "A" from table "Customers"
  • A.Select * From Customers Where CustomerName LIKE '%a%';
  • B.Select * From Customers Where CustomerName LIKE '_a%';
  • C.Select * From Customers Where CustomerName LIKE '%a';
  • D.Select * From Customers Where CustomerName LIKE 'a%';
20.SQL Syntax to get the Customers from 'India' And 'Us' from table "Customers"
  • A.Select * From Customers Where Country='India' AND Country='US';
  • B.Select * From Customers Where Country NOT IN ('India','US');
  • C.Select * From Customers Where Country IN ('India','US');
  • D.Select * From Customers Where Country Like '%India,US%');
21.SQL Syntax to get the Customers from new to old from table "Customers"
  • A.Select * From Customers;
  • B.Select * From Customers Order By CustomerId;
  • C.Select * From Customers Order By CustomerId ASC;
  • D.Select * From Customers Order By CustomerId DESC;
22.SQL Syntax to get 10 Customers from table "Customers"
  • A.Select TOP *10 From Customers;
  • B.Select 10 * From Customers;
  • C.Select TOP 10 * From Customers;
23.SQL Syntax to get Customers who's Address is null from table "Customers"
  • A.Select * From Customers Where Address NULL;
  • B.Select * From Customers Where Address IS NULL;
  • C.Select * From Customers Where Address=NULL;