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 the template in sql?
What is trigger explain with program?
What command is used to delete a table from the database in the sql server and how?
What are the security related catalog views? : sql server security
What is normalization of database? What are its benefits?
Explain the creation and execution of a user-defined function in the sql server?
Explain user defined views?
Do you know how to store and query spatial data?
What is the use of keyword with encryption.
How to encrypt data between dialogs?
What is dknf in normalization form?
What does select 1 mean?
What are the aggregate and scalar functions?
When should you use an instead of trigger?
How you would rewrite the sql query to return the customerid sorted numerically?