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 resource governor in sql server?
How do I delete a sql server database?
What is the purpose of update statistics and scope_identity() function?
Explain about system database?
What are the types of database schema? : sql server analysis services, ssas
Define cursor locking
Explain contrast amongst grouped and non-bunched records?
Explain activity monitors
What is replace and stuff function in sql server?
what are database files and filegroups? : Sql server database administration
What are trace files?
What is the difference between functions and stored procedures?
User wants only to display only pdf as export option in report manager. How to achieve this?
Define the one-to-one relationship while designing tables.
What is the default Port No on which SQL Server listens?