Solved

MS SQL search

Posted on 2014-04-13
4
277 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 68

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 68

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

APEX (Application Express) is used to develop a web application from Oracle. SQL Workshop is one of the tools that comes with Oracle APEX to query or modify the database objects or to make any changes to the structure.
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…
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…

943 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now