Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

why would you call update statistics? : Sql server database administration

1063


What are advantages of ssrs or why we should use ssrs?

137


difference between Clustered index and non clustered index ?

977


What is for xml in sql server?

1042


Is it possible to have clustered index on separate drive from original table location?

946


What is the osql utility?

941


What is a functions and types in sql server?

1063


Is it true, that there is no difference between a rule and a check constraint?

1021


Explain subquery and state its properties?

1020


How to create median function?

164


What is the maximum size of a dimension? : sql server analysis services, ssas

1025


What language is sql server written in?

1012


Explain the difference between primary keys and foreign keys?

1004


What different steps will a sql server developer take to secure sql server?

966


Mention the 3 ways to get a count of the number of records in a table.

961