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
What is BLOCK statements in SQL?
What is difference between foreign key and unique key?
Explain transaction server isolation?
What is the difference between clustered index and primary key?
What are differences in between sql server 2012 and sql server 2016?
How to stop log file growing too big?
What is the recovery model?
What is an execution plan? When would you use it?
What are the different types of sub-queries?
Name some of the open source software that you can use in alternative to SSR?
Do you know the policy based administration feature of sql server 2008?
What is #table in sql server?
What are the advantages to use stored procedures?
How to transfer data from a cursor to variables with a "fetch" statement?
what is database replication? : Sql server database administration