How can count the string ?
for ex: If i have string like 'bhaskar' then i need like
b:1
h:1
a:2
s:1
k:1
r:1

please give any idea on that


Answer Posted / suni soni

In SQL Server 2005 New query window for any database.

declare @CharVal varchar(100),@i int
declare @temp table (CharVal varchar(10))

set @a='Bhaskar'

set @i=1
while (@i<=len(@a))
begin

insert into @temp values (substring(@a,@i,1))

set @i=@i +1

end

select CharVal, count(*) from @temp group by CharVal

Is This Answer Correct ?    10 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is order of B+tree?

647


How can we use ConnectorJ JDBC Driver with MS SQL?

558


what are the three command line utilities and what are their primary functions?

101


Difference between connected and disconnected database in .net with sql server?

566


What is the contrast between sql and pl/sql?

616






How and why use sql server?

532


Difference between group by clause and having clause in SQL?

560


Can coalesce return null?

532


What is the difference between seek predicate and predicate?

577


What is the usage of sign function?

583


you have a table with close to 100 million records recently, a huge amount of this data was updated now, various queries against this table have slowed down considerably what is the quickest option to remedy the situation? : Sql server administration

533


What is SQL Azure Firewall?

116


What is role playing dimension with two examples? : sql server analysis services, ssas

580


What are statistics?

563


How to create a trigger for insert only?

593