Select chapter



Basics (2.papers)
Data Types (2.papers)
Table-designing (1.papers)
Queries-Commands (3.papers)
String functions (2.papers)
Subqueries (1.papers)
Joins (1.papers)
Constraints (1.papers)
Triggers (1.papers)
Hide

Sponsored Links


  

sql queries commands interview questions and answers

Please read the below given table for solving questions from 1 to 16
eidfnamelnameagesalarydeptdoj
1rajeevsukla2312000.net23-Oct-11 12:00:00 AM
2sowmyakumari2319000db13-Nov-10 12:00:00 AM
3kishorekumar2736000android16-Oct-11 12:00:00 AM
4abimanyubiswal22nullandroid25-May-10 12:00:00 AM
5sonikumar2421800.net21-Jun-09 12:00:00 AM
6anu_singh2212000db23-Oct-10 12:00:00 AM
7_dineshmoh%anty2315000.net26-Aug-09 12:00:00 AM
8nischala_kumari2218000db19-Jul-08 12:00:00 AM
9gouravchourasia2420000android06-Oct-13 12:00:00 AM
Note: Assume table is present in a database named skillgun , the Schema name is dbo and the table name as Employees ;
1
Which of the following syntax is a correct syntax for dropping a table?
  1. drop table table-name ;
  2. drop table-name ;
  3. drop * from table-name ;
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
2
What is the out put of the following query when the table is created by using the below given syntax ?
Table syntax: create table Students (sid int identity,sname varchar(40))
Query: insert into students values ('rajeev') ;
  1. Query results a parsing error ;
  2. Query will get compiled but is not executed and database engine will throw an exception.
  3. Query inserts 1 and rajeev as sid and sname values.
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
3
Which of the following query is used for displaying first 50% of the rows present in the given table ?
  1. select top 50 percent * from table-name ;
  2. select top 50 % * from table-name;
  3. select 50 percent * from table-name;
  4. select 50 % * from table-name ;
Show Answer
Share Facebook gmail Twitter
4
What is the use of like clause in T-SQL?
  1. like clause used for pattern matching in SQL.
  2. like clause used for searching only special characters present in a string.
  3. like clause is an alternative for where clause.
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
5
How to display the fnames which are starting with character a ?
  1. select fname from employees where fname starts with 'a%'
  2. select fname from employees where fname='a%'
  3. select fname from employees where fname = like 'a%'
  4. select fname from employees where fname like 'a%'
Show Answer
Share Facebook gmail Twitter
6
Which of the following query is used for displaying the fnames which are ending with character 'v' ?
  1. select fname from employees where fname like '%v%'
  2. select fname from employees where fname='%v%'
  3. select fname from employees where fname like '_v%'
  4. select fname from employees where fname like '%v'
Show Answer
Share Facebook gmail Twitter
7
Which of the following query returns all the employees details whose fname is having character 'o' in the second position?
  1. select * from employees where fname like '_o%'
  2. select * from employees where fname like '[]o%'
  3. select * from employees where fname like '{1}o%'
  4. None of the above .
Show Answer
Share Facebook gmail Twitter
8
which of the following query returns all the employees details whose fname is having character 'y' in the last but one  position?
  1. select * from employees where fname like '%y%_'
  2. select * from employees where fname like '%y_%'
  3. select * from employees where fname like '%y{^1}%'
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
9
Which of the following query used for deleting all the employees whose fname is having character 'n' any where between first and last character ?
  1. Delete from employees where fname like '%_n_%'
  2. Delete from employees where fname like '_%n%_'
  3. Delete from employees where fname like '%n%'
  4. None of the above .
Show Answer
Share Facebook gmail Twitter
10
Which of the following query returns all the employees whose fname is having character underscore any where?
  1. select * from employees where fname like '%[_]%'
  2. select * from employees where fname like '%_%'
  3. select * from employees where fname like '_%'
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
11
Which of the following query returns all the employees whose fname is having percentage character any where?
  1. select * from employees where fname like '%\%%'
  2. select * from employees where fname like '%%%'
  3. select * from employees where fname like '%[%]%'
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
12
Which of the following query displays all the employees details whose lnames are having % character any where?
  1. select * from employees where lname like '%[%]%'
  2. select * from employees where lname like '%^%%' escape '^'
  3. Both first and second options are valid .
  4. None of the given options are correct .
Show Answer
Share Facebook gmail Twitter
13
Syntax for delete command in SQL(identify the correct syntax)?
Note: Items placed in square brackets are optional .
  1. delete table-name [ where <condition> ]
    
  2. delete * from table-name [where <condition>] 
  3. delete from table-name [ where <condition> ]
  4. First and third options are correct.
Show Answer
Share Facebook gmail Twitter
14
Syntax for update command in SQL(identify correct syntax)?
Note: Items placed in square brackets are optional.
  1. update table-name set column-name1=value1,column-name2=value2,….. [ Where <condition> ]
  2. update from table-name set column-name1=value1,column-name2=value2,… [ Where <condition> ]
Show Answer
Share Facebook gmail Twitter
15
What is the use of as keyword in SQL?
  1. In SQL,  as keyword can be used for changing the column name in the result set.
  2. In SQL, as keyword can be used for alias naming.
  3. Both first and second options are valid.
Show Answer
Share Facebook gmail Twitter
16
Which of the following query/queries deletes duplicate data present in employees table using table variable ?
  1. declare @v table (c1 int,c2 varchar(40),c3 varchar(40),c4 int,c5 int,dept varchar(40),doj date );
    insert into @v select distinct * from employees ;
    delete employees;
    insert into employees select * from @v;
  2. select distinct * into @v from employees ;
    delete employees;
    insert into employees select * from @v;
  3. declare @v table (c1 int,c2 varchar(40),c3 varchar(40),c4 int,c5 int,dept varchar(40),doj date );
    insert into @v select * from employees ;
    delete employees;
    insert into employees select * from @v;
  4. select * into @v from employees ;
    delete employees;
    insert into employees select * from @v;
Show Answer
Share Facebook gmail Twitter
Read more papers :