hi,
it is batch code it gives revers of all rows in the table........
i think this is good solution for --reversing data with out using REVERSE() function
create table std
(id int identity,
name varchar(20))
insert into std(name)
values ('abhijeet'),('omkar'),('tushar')
create table #table
(id int ,
name varchar(20))
declare @STR varchar(20)
--if exists(select * from std)
--begin
declare @count int
set @count=(select COUNT(*) from std)
--declare @tempcntid int=@count
declare@i int=@count
--while exists(select * from std)
while @i!=0
begin
set @STR=(select name from std where id=@i)
declare@str2 varchar(20)=' '
declare @j-2 int=1
while @j-2<=LEN(@str)
begin
set @str2=SUBSTRING(@str,@j,1)+ @str2
set @j-2=@j+1
end
--print @str2
insert into #table(id,name)values(@i,@str2)
--set @tempcntid=@tempcntid-1
set @i=@i-1
end
go
select * from std
go
select * from #table
go