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

Explain the microsoft sql server delete command?

1024


Which is better statement or preparedstatement?

930


What is tcl in sql server?

1126


Is it possible for a stored procedure to call itself or recursive stored procedure? How many levels of sp nesting are possible?

881


What is outer join in sql server joins?

1121


Can you pass expressions to function parameters?

1103


What is row_number () and partition by in sql server?

1081


Explain about SQLOS?

1013


What is recursion? Is it possible for a stored procedure to call itself or recursive stored procedure?

1002


What is the difference between DATETIME2 and DATETIME?

1081


What is a cursor, index in sql?

1071


what is new philosophy for database devises for sql server 7.0? : Sql server database administration

1010


How does using a separate hard drive for several database objects improves performance right away?

934


How to scale out a federation by Sql statement?

116


what is checksum in sql server.........???

1686