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 to make remote connection in database?

1053


Determine when an index is appropriate?

1132


Where can you add custom error messages to sql server?

1164


How exceptions can be handled in sql server programming?

1077


What is the status of services on passive node for failover cluster in sql server? : sql server database administration

1354


How to list all field names in the result set using mssql_field_name()?

952


What is the purpose of sql profiler in sql server? : sql server database administration

1162


How to add additional conditions in SQL?

1069


How to rebuild master databse?

1130


Can you name a few encryption mechanisms in sql server?

993


What is resultset concur_updatable?

1056


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

1181


How to handle error or exception in sql?

1040


What is a system database and what is a user database?

1140


What are the types of table?

1031