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

What is BLOCK statements in SQL?

1206


What is difference between foreign key and unique key?

962


Explain transaction server isolation?

980


What is the difference between clustered index and primary key?

869


What are differences in between sql server 2012 and sql server 2016?

978


How to stop log file growing too big?

955


What is the recovery model?

931


What is an execution plan? When would you use it?

919


What are the different types of sub-queries?

994


Name some of the open source software that you can use in alternative to SSR?

151


Do you know the policy based administration feature of sql server 2008?

905


What is #table in sql server?

998


What are the advantages to use stored procedures?

1032


How to transfer data from a cursor to variables with a "fetch" statement?

1020


what is database replication? : Sql server database administration

986