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 to make remote connection in database?
Determine when an index is appropriate?
Where can you add custom error messages to sql server?
How exceptions can be handled in sql server programming?
What is the status of services on passive node for failover cluster in sql server? : sql server database administration
How to list all field names in the result set using mssql_field_name()?
What is the purpose of sql profiler in sql server? : sql server database administration
How to add additional conditions in SQL?
How to rebuild master databse?
Can you name a few encryption mechanisms in sql server?
What is resultset concur_updatable?
How to insert multiple rows with one insert statement in ms sql server?
How to handle error or exception in sql?
What is a system database and what is a user database?
What are the types of table?