Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 Posted / shunmuga priya

--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 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is it safe to delete log files?

899


What is the distinction amongst delete and truncate?

1043


Explain transaction isolation levels in sql server?

1093


How is sql server used?

946


What Is Rdbms?

1132


what are isolation levels? : Sql server database administration

969


How to create function without parameter in sql server?

1040


What types of replication are supported in sql server?

1048


What is the use of sql profiler in sql server 2012?

873


Explain the difference between cross join and full outer join?

965


Sql server reporting services vs. Crystal reports.

131


What are the types of normalization?

1013


How to insert data with null values?

1006


Determine when to use stored procedure to complete sql server tasks?

1035


What are the differences between char and varchar in ms sql server?

1043