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
How is foreign key related to primary key?
What the different components of Replication and what is their use?
What are page splits?
What is best institute to Learn DotNET And SQL in chennai?
What is dimension table? : sql server analysis services, ssas
Does the unique constraint create an index?
What is a database table?
How to recreate an existing index in ms sql server?
How do I partition a table in sql server?
How to compare the top two records using sql?
What is merge join?
Explain transaction server implicit?
How to insert multiple rows with one insert statement in ms sql server?
How to change the name of a database user?
What is the difference between functions and stored procedures?