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 / deepak
declare @Str As varchar(100)
declare @StrNew As varchar(100)
-- You can set any string (max 100 len)
set @Str = 'Bhaskar'
set @StrNew = @Str
declare @PrintVal varchar(10)
While @StrNew <> ''
BEGIN
set @StrNew = Replace(@Str, left(@Str, 1), '')
set @PrintVal= (left(@Str,1) + cast((len(@Str)-Len
(@StrNew)) as varchar(5)))
print @PrintVal + ' ' + @StrNew +' ' +@Str
set @Str = @StrNew
END
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
why would you call update statistics? : Sql server database administration
What are advantages of ssrs or why we should use ssrs?
difference between Clustered index and non clustered index ?
What is for xml in sql server?
Is it possible to have clustered index on separate drive from original table location?
What is the osql utility?
What is a functions and types in sql server?
Is it true, that there is no difference between a rule and a check constraint?
Explain subquery and state its properties?
How to create median function?
What is the maximum size of a dimension? : sql server analysis services, ssas
What language is sql server written in?
Explain the difference between primary keys and foreign keys?
What different steps will a sql server developer take to secure sql server?
Mention the 3 ways to get a count of the number of records in a table.