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)
 How able to see and whitespace characters

Author  Topic 

johnsql
Posting Yak Master

161 Posts

Posted - 2007-11-09 : 12:25:48
In a varchar(50)-typed column col1 of a table there are some blanks that can be located in any position in that column. Also, all kinds of readable characters of keyboard can take place in the column contents.
How can we to recognize ("see") such whitespaces(e.g. blank, etc.) that are mixed with other readable in column col1?
Thanks,
johnsql

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-11-09 : 12:29:36
try viewing your data in text mode in QA

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page

johnsql
Posting Yak Master

161 Posts

Posted - 2007-11-09 : 12:32:50
To be clear,
Blanks can be seen but what I'd like that I can count how many blanks between non-blank chacters.
For example, if col1=' 23 9~[] #%% ', then I can see there are blanks between substrings "23" and "9~[]", but I can NOT count how many there are such blanks between those 2 substrings.
Any idea?
Go to Top of Page

johnsql
Posting Yak Master

161 Posts

Posted - 2007-11-09 : 12:34:05
quote:
Originally posted by spirit1

try viewing your data in text mode in QA

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com



Spirit,
Thanks for your post, however,
To be clear,
Blanks can be seen but what I'd like that I can count how many blanks between non-blank chacters.
For example, if col1=' 23 9~[] #%% ', then I can see there are blanks between substrings "23" and "9~[]", but I can NOT count how many there are such blanks between those 2 substrings.
Any idea?
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-11-09 : 12:37:56
oh...
then do:
select len(YourColum) - len(replace(YourColum, ' ', ''))
from yourTable

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page

johnsql
Posting Yak Master

161 Posts

Posted - 2007-11-09 : 13:33:18
quote:
Originally posted by spirit1

oh...
then do:
select len(YourColum) - len(replace(YourColum, ' ', ''))
from yourTable

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com



What if blanks appear at the beginning or end of col1? It seems, in those scenarios, replace() functions do not work properly.
Do you have any idea?

Thank you in advance,
Go to Top of Page

johnsql
Posting Yak Master

161 Posts

Posted - 2007-11-09 : 13:37:36
quote:
Originally posted by johnsql

quote:
Originally posted by spirit1

oh...
then do:
select len(YourColum) - len(replace(YourColum, ' ', ''))
from yourTable

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com



What if blanks appear at the beginning or end of col1? It seems, in those scenarios, replace() functions do not work properly.
Do you have any idea?

Thank you in advance,



I think in such scenarios, LEN() function excludes counting trailing blanks. So, len(YourColum) does not properly. It counts less, so len(YourColum) - len(replace(YourColum, ' ', '')) returns smaller results.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-11-09 : 13:43:24
Use DATALENGTH instead.
Also, it might not be ASCII32 (space) as the spacing character. Look for ASCI160 too.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-11-09 : 13:43:25
well then use datalength instead of len

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-11-09 : 13:44:34
1 second



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-11-09 : 13:45:42
ouch!! that's the closest one yet

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page

johnsql
Posting Yak Master

161 Posts

Posted - 2007-11-09 : 14:04:45
Thank you all of you. DATALENGTH() works perfect.
Go to Top of Page
   

- Advertisement -