• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 285
  • 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,
  • 2
1 Solution
QlemoBatchelor and DeveloperCommented:
You don't need a function. A simple expression works:
where replace('0101 10 100 0', ' ', '') = replace(tariff, ' ', '')

Open in new window

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',' ','')

look out here for few examples and syntax

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...
QlemoBatchelor and DeveloperCommented:
That is exactly what I showed - you can do anything in the where clause.
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

A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.

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