• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 286
  • Last Modified:

MS SQL search

Hi everyone,
I create a table with tariff... The tariff number is withe following structure:
0101 10
0101 10 100 0
0101 10 900 0
0101 90
The field is set as varchar since a lot of  tariff numbers has 0 in front...
I need to create function  for search the table and to ignore the empty space...
Thank you in advance,
Andreja
0
andrejaTJ
Asked:
andrejaTJ
  • 2
1 Solution
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
You don't need a function. A simple expression works:
where replace('0101 10 100 0', ' ', '') = replace(tariff, ' ', '')

Open in new window

0
 
Wasim Akram ShaikCommented:
you can use replace function clause to ignore the space character ' '

this will replace the space with normal string and can perform the search as if there was no space ie., ' ' space character can get replaced with '' non-space character

select replace('0101 10',' ','')
GO

look out here for few examples and syntax

http://technet.microsoft.com/en-us/library/ms186862.aspx
0
 
andrejaTJAuthor Commented:
TX Wasin & QLemo, to remove the space is not a problem.
but I cannot change the tariff number... So a query or function for searching among tariff numbers without changing them... That's what I need...
Best,
Andreja
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
That is exactly what I showed - you can do anything in the where clause.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now