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 snapshot replication?
which backup strategy you are following at ur company
What is store procedure? When do you use?
Can we shrink data file in sql server?
What does asynchronous call backs means?
How do I run sql server 2014?
Does index slows down insert statements?
What is difference between Datepart() and Datename() in SqlServer?
Explain how many types of relationship?
What is resource db in sql server?
Define self join?
How to change the name of a database user?
Explain temporary table vs table variable by using cursor alternative?
What is the new security features added in sql server 2016? : sql server security
Explain what are commit and rollback in sql?