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
Is it safe to delete log files?
What is the distinction amongst delete and truncate?
Explain transaction isolation levels in sql server?
How is sql server used?
What Is Rdbms?
what are isolation levels? : Sql server database administration
How to create function without parameter in sql server?
What types of replication are supported in sql server?
What is the use of sql profiler in sql server 2012?
Explain the difference between cross join and full outer join?
Sql server reporting services vs. Crystal reports.
What are the types of normalization?
How to insert data with null values?
Determine when to use stored procedure to complete sql server tasks?
What are the differences between char and varchar in ms sql server?