?
Solved

MS SQL search

Posted on 2014-04-13
4
Medium Priority
?
282 Views
Last Modified: 2014-04-13
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
Comment
Question by:andrejaTJ
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 70

Expert Comment

by:Qlemo
ID: 39997612
You don't need a function. A simple expression works:
where replace('0101 10 100 0', ' ', '') = replace(tariff, ' ', '')

Open in new window

0
 
LVL 16

Expert Comment

by:Wasim Akram Shaik
ID: 39997617
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
 

Author Comment

by:andrejaTJ
ID: 39997634
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
 
LVL 70

Accepted Solution

by:
Qlemo earned 1000 total points
ID: 39997770
That is exactly what I showed - you can do anything in the where clause.
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question