ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
 
Categories  >>  Software  >>  Databases  >>  SQL Server
 
 


 

 
 Oracle interview questions  Oracle Interview Questions
 SQL Server interview questions  SQL Server Interview Questions
 MS Access interview questions  MS Access Interview Questions
 MySQL interview questions  MySQL Interview Questions
 Postgre interview questions  Postgre Interview Questions
 Sybase interview questions  Sybase Interview Questions
 DB Architecture interview questions  DB Architecture Interview Questions
 DB Administration interview questions  DB Administration Interview Questions
 DB Development interview questions  DB Development Interview Questions
 SQL PLSQL interview questions  SQL PLSQL Interview Questions
 Databases AllOther interview questions  Databases AllOther Interview Questions
Question
i have a table student like
sname
-----
ram
ram
ram
raj
raj
raj
i need the output like
sname
-----
ram
raj
ram
raj
ram
raj
 Question Submitted By :: Durga Prasad
I also faced this Question!!     Rank Answer Posted By  
 
  Re: i have a table student like sname ----- ram ram ram raj raj raj i need the output like sname ----- ram raj ram raj ram raj
Answer
# 1
select e1.sname,e2.sname from emp e1,emp e2 where e1.sname 
= 'ram' 
and e2.sname = 'raj';
 
Is This Answer Correct ?    3 Yes 8 No
Chitram
 
  Re: i have a table student like sname ----- ram ram ram raj raj raj i need the output like sname ----- ram raj ram raj ram raj
Answer
# 2
;with TEST as (select Row_Number() over (partition by sname 
order by sname) as ROWNO,sname from student)
select sname from TEST order by ROWNO,(case when sname 
= 'RAM' then 1
                             when sname = 'RAJ' then 2 end)
 
Is This Answer Correct ?    6 Yes 0 No
Sagun Sawant
 
 
 
  Re: i have a table student like sname ----- ram ram ram raj raj raj i need the output like sname ----- ram raj ram raj ram raj
Answer
# 3
select (substring(name,1,3)+' '+substring(name,13,3)
+' '+substring(name,5,3)+' '+substring(name,17,3)
+' '+substring(name,9,3)+' '+substring(name,21,3))name
from employee where name like '%raj%'
 
Is This Answer Correct ?    1 Yes 2 No
Deepak Rohilla
 
  Re: i have a table student like sname ----- ram ram ram raj raj raj i need the output like sname ----- ram raj ram raj ram raj
Answer
# 4
--The query to work in SQL server 2000
declare @cnt int
select @cnt = count(sname) from student where sname ='ram'

declare @student table
(sname varchar(20))

while @cnt <> 0
begin
insert @student 
select * from student where sname like 'raj'
union
select * from student where sname like 'ram'
order by sname desc
set @cnt = @cnt - 1
End

select * from @student
 
Is This Answer Correct ?    3 Yes 0 No
Shunmuga Priya
 
  Re: i have a table student like sname ----- ram ram ram raj raj raj i need the output like sname ----- ram raj ram raj ram raj
Answer
# 5
select a.tnam,b.tnam from (select tnam from temp where tnam 
= 'Ram' ) a,
(select tnam from temp where tnam = 'Raj' ) b
 
Is This Answer Correct ?    0 Yes 2 No
Mala
 
  Re: i have a table student like sname ----- ram ram ram raj raj raj i need the output like sname ----- ram raj ram raj ram raj
Answer
# 6
select ename from (select Row_Number() over (partition by 
ename 
order by ename) as ROWNO,ename from emp) p
 order by ROWNO,ename desc
 
Is This Answer Correct ?    2 Yes 0 No
Bobby
 
  Re: i have a table student like sname ----- ram ram ram raj raj raj i need the output like sname ----- ram raj ram raj ram raj
Answer
# 7
select sname from (select Row_Number() over (partition by 
sname 
order by sname) as ROWNO,sname from student) p
 order by ROWNO,sname desc


only change table name same as bobby
 
Is This Answer Correct ?    0 Yes 0 No
Pradip Jain
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
How can u convert the Date to String? TCS4
How to write query to Delete the records in child table and corresponding records in parent table Semantic-Space8
Which system table contains information on constraints on all the tables created?  2
A table contains list of customers and his city with other details. Each customer has a unique number and the table consists millions of data. Query is: I want to retrieve 10 customers from each city, no script, only from single query? Infosys3
how to find out the repeated value from table using groupby function?  3
What is normalization and what are the different forms of normalizations?  1
What should we do to copy the tables, schema and views from one SQL Server to another?  3
wat will be the sql query to extract only last 3 records from table supose table hving thousands for records  16
Questions regarding Raiseerror?  1
What is a transaction and what are ACID properties?  2
What is user stored procedure & it purpose? Wipro3
How do you find the error, how can you know the number of rows effected by last SQL statement?  2
What is database replicaion? What are the different types of replication you can set up in SQL Server? HCL4
any one can explain Self mapping Delegation Remote Credentials  1
i have a table student like sname ----- ram ram ram raj raj raj i need the output like sname ----- ram raj ram raj ram raj IBM7
I have a table EMP in which the values will be like this EmpId Ename Sal DeptId 11 Ram 10000 10 11 Ram 10000 10 22 Raj 20000 20 22 Raj 20000 20 33 Anil 15000 30 33 Anil 15000 30 I want to delete only duplicate Rows. After Delete I want the output like this EmpId Ename Sal DeptId 11 Ram 10000 10 22 Raj 20000 20 33 Anil 15000 30 DELL10
What are tasks? Wipro1
What are cursors?  8
Can I remove the default constraint columns in SQL SERVER? Value-Labs3
Wht is SQL Injection Attack ?  1
 
For more SQL Server Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com