adspace


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

How do I find query history in sql server?

1025


What is a scheduled job or what is a scheduled task?

1040


You have a stored procedure, which execute a lengthy batch job. This stored procedure is called from a trigger you do not want to slow the data entry process you do not want trigger to wait for this batch job to finish before it completes itself what you can do to speed up the process?

1215


What are the different types of subquery?

1235


What are the different SQL Server Versions you have worked on?

1080


Disadvantages of the indexes?

1225


What is in place upgrade in sql server?

1127


When should you use an instead of trigger?

1054


How to connect php with different port numbers?

1191


How to enter binary string literals in ms sql server?

1246


What is a view in sql?

1043


What is the difference between upgrade and migration in sql server?

1185


What are the risks of storing a hibernate-managed object in a cache? How do you overcome the problems?

1200


List the ways in which dynamic sql can be executed?

1087


do you know how to configure db2 side of the application? : Sql server database administration

1125