Solved

MS SQL search

Posted on 2014-04-13
4
279 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
  • 2
4 Comments
 
LVL 69

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 69

Accepted Solution

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

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

860 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