Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Count characters in SQL 2000

Author  Topic 

superhero
Yak Posting Veteran

52 Posts

Posted - 2007-01-26 : 04:44:20
Hi Everyone

I'm developing in VB.net 2 with SQL 2000 Enterprize.

The company I work for does off-site record storage. We have a lot of indexers that physically type and index these files manually on our system. They get paid per character they type.

I would like to give the users a way of checking how many character they have typed. Right now I do a simple "Select field1, field2 from indexdata where indexername = John and indexdate > 01/01/2007 and indexdate < 01/02/2007". I then loop through the records, adding everyting to a string variable and doing a len(stringvariable) in vb. This works great, no problems at all. It just takes long. 'Cause I have to transfer all the data to the users' pc just to count the characters. The indexers can't type a lot of blank spaces - my software checks for that, so whatever is in the DB is the correct characters. I just simply need to count them!

I know in SQL you have the COUNT function that can return number of rows. Does anyone know of a way of letting the SQL server count the characters and simply return an integer to the user? It would just speed things up a lot!

Thanks

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-26 : 04:48:12
[code]SELECT SUM(LEN(Field1) + LEN(Field2)) AS Characters
FROM IndexData
WHERE IndexerName = 'John'
AND IndexDate >= '20070101'
AND IndexDate < '20070201'[/code]

Peter Larsson
Helsingborg, Sweden
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-01-26 : 04:49:05
there is also a len() function for string in SQLServer


KH

Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-01-26 : 04:50:02


Do we also get paid for every character we type here ?


KH

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-26 : 04:57:20
Is that your $0.02 ?



Peter Larsson
Helsingborg, Sweden
Go to Top of Page

superhero
Yak Posting Veteran

52 Posts

Posted - 2007-01-26 : 04:59:55
Wow Peter that was a quick reply! Maybe we should employ you as an indexer!

Your $0.02 is in the post, thanks it worked like a bomb dude.

Dawie
Go to Top of Page
   

- Advertisement -