-
Counting character in a column value
Anybody know, How can we count a character in a column value
-
Re: Counting character in a column value
at least in 7 you would need to loop through the column value using
CHARINDEX and set a variable to increment for each occurence.
--
HTH,
David Satz
Principal Software Engineer
Hyperion Solutions
->Using SQL Server 7.0 SP3/6.5 SP5a/Cold Fusion 4.5.1 SP2/VSS
(Please reply to group only - emails answered rarely)
-----------------------------------------------------------------
"pm" <pmsep2000@hotmail.com> wrote in message
news:3b3ca5fc$1@news.devx.com...
>
> Anybody know, How can we count a character in a column value
-
Re: Counting character in a column value
T-SQL: Len(string)
Dan Vernet
"pm" <pmsep2000@hotmail.com> wrote:
>
>Anybody know, How can we count a character in a column value
-
Re: Counting character in a column value
I assume pm meant to count the occurence of a character (or expression)
within a character-type column ???
"Zara" <dvernet@kos.net> wrote in message news:3b3cc3f2$1@news.devx.com...
>
> T-SQL: Len(string)
>
> Dan Vernet
>
> "pm" <pmsep2000@hotmail.com> wrote:
> >
> >Anybody know, How can we count a character in a column value
>
-
Re: Counting character in a column value
you are right Dave.
But How can I do it store proc dynamically?
"DaveSatz" <davidsatz@yahoo.com> wrote:
>I assume pm meant to count the occurence of a character (or expression)
>within a character-type column ???
>
>"Zara" <dvernet@kos.net> wrote in message news:3b3cc3f2$1@news.devx.com...
>>
>> T-SQL: Len(string)
>>
>> Dan Vernet
>>
>> "pm" <pmsep2000@hotmail.com> wrote:
>> >
>> >Anybody know, How can we count a character in a column value
>>
>
>
-
Re: Counting character in a column value
something like:
DECLARE @Str varchar(30 )
, @LookFor char(1)
,@Occurences int
,@Pos int
,@newPos int
SET @Str = 'abc.07/07/2000*x?'
SET @LookFor = "0" -- "/"
SET @Occurences = 0
SET @Pos = CHARINDEX( @LookFor , @Str )
WHILE @Pos > 0
BEGIN
SET @Occurences = @Occurences + 1
SET @NewPos = @Pos+1
SET @Pos = CHARINDEX( @LookFor , @Str, @NewPos )
END
SELECT @Occurences
GO
"pm" <pmsep2000@hotmail.com> wrote in message
news:3b3ce15b$1@news.devx.com...
>
> you are right Dave.
> But How can I do it store proc dynamically?
>
>
> "DaveSatz" <davidsatz@yahoo.com> wrote:
> >I assume pm meant to count the occurence of a character (or expression)
> >within a character-type column ???
> >
> >"Zara" <dvernet@kos.net> wrote in message
news:3b3cc3f2$1@news.devx.com...
> >>
> >> T-SQL: Len(string)
> >>
> >> Dan Vernet
> >>
> >> "pm" <pmsep2000@hotmail.com> wrote:
> >> >
> >> >Anybody know, How can we count a character in a column value
> >>
> >
> >
>
-
Re: Counting character in a column value
hi!
there's a system function 'Len', this will give you the number of characters,
including spaces.
JC
"pm" <pmsep2000@hotmail.com> wrote:
>
>Anybody know, How can we count a character in a column value
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks