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.
Author |
Topic |
fizzer
Starting Member
10 Posts |
Posted - 2006-10-18 : 09:58:20
|
Hi,I have the following query:SELECT TimeZone FROM PostalCodesTable WHERE PostalCode='H1A2W6'Some of the postcodes are stored in the database with spaces and some without. The user can only enter postcodes without spaces. So how Would I get a match if for in the above example case, the postcode was stored as 'H1A 2W6'? |
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2006-10-18 : 10:05:36
|
Look up "Replace" in BOL (Books Online) or do a search for "Whitespace" here on these forums.[Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQLhttp://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
fizzer
Starting Member
10 Posts |
Posted - 2006-10-18 : 11:07:11
|
Iv'e looked at the REPLACE function but not sure that that's what I need. ie. In my first post, I would have to add a space not replace anything.The reason for this (I think) is that I cannot use the REPLACE in the Where Clause.EDITED:- ignore my post this seems to work:SELECT TimeZoneFROM PostalCodesTable WHERE REPLACE(PostalCode,' ','') ='H1A2W6'Many thanks |
 |
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2006-10-18 : 14:45:47
|
It is always BEST when you solve your own problem. I will bet you learned a LOT more by finding the answer than having it given to you. [Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQLhttp://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
|
|