Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 13th, 2004, 06:26 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default Looks like a space but it isn't.

Hello all,

I just imported an Excel speadsheet into a SQL 2000 database. I'm trying to join that data with some other tables. I noticed that there is a space or what looks like a space after every entry in the column and wherever there is a space between words. I want to join to the data in but I cannot get rid of the space with the rtrim and ltrim functions. And replacing spaces with nothing wouldn't work, one because its not a space and two if it was a space and removed the spaces between words I wouldn't be able to join to the column.

I found a work-around by doing a 'left' on the length - 1 and ended up copying what looked like the space character into a 'replace' function and that worked.

Does anyone know what that character is? In the future I would simply like to replace that character with a space and then 'rtrim/ltrim' the data.

Thank you.

Cheers,
Richard

 
Old December 14th, 2004, 01:28 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

I think it is not space but tab charecter. you can check for vbTab in replace function.

Om Prakash
 
Old December 16th, 2004, 03:40 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

Hi Om,

Thank you for your reply.

I tried replace with 'vbTab' and that doesn't remove the space either.

Any other suggestions?

What I was able to do though was to copy the space from the database and replace it with a "real" space from the 'space bar' on the keyboard for entries that have spaces between words. Never have I seen such a problem.

Thanks,
Richard

 
Old September 7th, 2005, 07:17 PM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 385
Thanks: 0
Thanked 0 Times in 0 Posts
Default

There are a number of "extended asci" values that can appear as a blank. You need to find out what the value is then use the SQL replace function to get rid of it. Use the ascii() function to find out what it is first though. It would be something along these lines.

select char(255)
select ascii('x')

for the field and row where you get the blank/tab/???
select ascii(right(fieldx,1))

This should give you an asci value, whatever that value is put it in the statement below replacing the 255

REPLACE(fieldx,char(255),'')

This will replace the offending value with nothing, thus removing it.







Similar Threads
Thread Thread Starter Forum Replies Last Post
space is not working.. gantait XSLT 5 February 26th, 2007 04:39 AM
space crmpicco Javascript How-To 1 February 7th, 2005 01:26 PM
Unwanted space... again Snib HTML Code Clinic 1 August 25th, 2004 04:45 PM
space hassles Adam H-W HTML Code Clinic 16 June 30th, 2004 04:09 PM
Space in URL lian_a Classic ASP Basics 5 June 23rd, 2004 11:29 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.