Yes, there is. And you'd be surprised if you found out its name: Len!! ;-)
Syntax:
LEN ( string_expression )
Example:
SELECT LEN (Field1) AS 'Length', Field2 FROM aTable
This will return the length of field1
HtH
Imar
At 04:07 PM 2/9/2001 +0000, you wrote:
>I would like to write a code something like that in the stored procedure.
>My code is something like this
>
>/* fetch a record */
> FETCH NEXT FROM tblCursor INTO @id, @seq
>
>/* loop through the database */
> DECLARE @start int
> WHILE (@@FETCH_STATUS = 0)
> BEGIN
>
>/* create a new string */
>/* new string has a comma inserted after every 2 char */
> SET @newStr = ""
> SET @start = 1
> SET @newStr = RTRIM (@newSTr) + SUBSTRING (@seq, @start, 2)
> SET @start = @start + 2
>
>/* loop throught the string */
> WHILE (@start < 63)
> BEGIN
>
>/* put comma */
> SET @newStr = RTRIM (@newSTr) + "," + SUBSTRING (@seq, @start, 2)
>
>/* reset */
> SET @start = @start + 2
> END
> FETCH NEXT FROM tblCursor INTO @id, @seq
> END
>
>Right now I hard-coded the code as
> WHILE (@start < 63)
>But I like to replace 63 with the length of the @seq
>
>Is there a equivalent of the vbscript function Len () for SQL. Thanks.
>-ann