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

How is foreign key related to primary key?

1010


What the different components of Replication and what is their use?

1123


What are page splits?

1048


What is best institute to Learn DotNET And SQL in chennai?

2219


What is dimension table? : sql server analysis services, ssas

1064


Does the unique constraint create an index?

1131


What is a database table?

1021


How to recreate an existing index in ms sql server?

1113


How do I partition a table in sql server?

1097


How to compare the top two records using sql?

1409


What is merge join?

1235


Explain transaction server implicit?

1025


How to insert multiple rows with one insert statement in ms sql server?

1176


How to change the name of a database user?

1007


What is the difference between functions and stored procedures?

1220