Solved

MS SQL search

Posted on 2014-04-13
4
275 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
That is exactly what I showed - you can do anything in the where clause.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Creating and Managing Databases with phpMyAdmin in cPanel.
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
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…

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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now