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
What is order of B+tree?
How can we use ConnectorJ JDBC Driver with MS SQL?
what are the three command line utilities and what are their primary functions?
Difference between connected and disconnected database in .net with sql server?
What is the contrast between sql and pl/sql?
How and why use sql server?
Difference between group by clause and having clause in SQL?
Can coalesce return null?
What is the difference between seek predicate and predicate?
What is the usage of sign function?
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
What is SQL Azure Firewall?
What is role playing dimension with two examples? : sql server analysis services, ssas
What are statistics?
How to create a trigger for insert only?