SQL 2000.
I need a query that will search a field in the table that is 14
characters long and begins with a number.
I have a client that was allowing people to store credit card numbers,
plain text, in an application. I need to rip through the table and
replace every instance of credit card numbers with "x" and the last 4
digits. I got the replace bit going, but I am stuck on how to search
for a string in a field of a specific length.
Any ideas?
Thanks,
--Mike 5 4806
select * from MyTable where len(reference) = 2 and
SUBSTRING (reference ,1 ,1 ) IN ('0','1','2','3 ','4','5','6',' 7','8','9')
you could expand and use the ISNUMERIC()
--
Jack Vamvas
_______________ _______________ _____
Need an IT job? http://www.ITjobfeed.com
<mi**@mcarlson. netwrote in message
news:11******** *************@1 9g2000hsx.googl egroups.com...
SQL 2000.
I need a query that will search a field in the table that is 14
characters long and begins with a number.
I have a client that was allowing people to store credit card numbers,
plain text, in an application. I need to rip through the table and
replace every instance of credit card numbers with "x" and the last 4
digits. I got the replace bit going, but I am stuck on how to search
for a string in a field of a specific length.
Any ideas?
Thanks,
--Mike
On Fri, 14 Sep 2007 07:19:25 -0700, mi**@mcarlson.n et wrote:
>SQL 2000.
I need a query that will search a field in the table that is 14 characters long and begins with a number.
Hi Mike,
WHERE LEN(YourColumn) = 14
AND LEFT(YourColumn , 1) LIKE '[0-9]'
>I have a client that was allowing people to store credit card numbers, plain text, in an application. I need to rip through the table and replace every instance of credit card numbers with "x" and the last 4 digits. I got the replace bit going, but I am stuck on how to search for a string in a field of a specific length.
Are you sure you need to check only the first character for numeric? All
my credit cards have only numbers. To test for length 14 and only
numbers, you can change the above to
WHERE LEN(YourColumn) = 14
AND YourColumn NOT LIKE '%[^0-9]%'
--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
On Fri, 14 Sep 2007 21:38:51 +0000 (UTC), Erland Sommarskog wrote:
>Hugo Kornelis (hu**@perFact.R EMOVETHIS.info. INVALID) writes:
>Are you sure you need to check only the first character for numeric? All my credit cards have only numbers. To test for length 14 and only numbers, you can change the above to
WHERE LEN(YourColumn) = 14 AND YourColumn NOT LIKE '%[^0-9]%'
And my two credit-cards have 16-digit numbers...
Heh! So has mine - I didn't even think of that while posting my reply.
--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
>I have a client that was allowing people to store credit card numbers in plain text, in an application. I need to rip through the table and replace every instance of credit card numbers with "x" and the last 4 digits. <<
You might want to learn the difference between a field and column
before you write anymore SQL -- like what a constraint is. I assume
that youmeant 16 digits, broken into groups of 4 digits.
UPDATE Foobar
SET creditcard_nbr
= 'xxxx-xxxx-xxxx-" + SUBSTRING( creditcard_nbr, 13, 16);
Having done this, put all of this in the DDL. Mop the floor,but fix
the leak!! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: todd |
last post by:
here is a search tool SP I wrote.
How many times have you wanted to search all your Stored procs or views (in
a
database) for a keyword but couldn't!?
Well now you can! THis can makes life a lot easier for developers.
Would you email me and let me know which part of the world my code is
running in?
|
by: Ryan |
last post by:
I'm looking for a stored procedure (or query) to search an entire
database for a specific string value and replace it with another. I'm
sure I saw an SP for this a while back by someone, but cannot find it
again. The SP took the search string and replace string as parameters
and did the rest. Any ideas where I can find this ?
Bear in mind, the idea is that this can be re-used and run on any
database, so it would have to find all tables...
|
by: Phlip |
last post by:
C++ers:
Here's an open ended STL question. What's the smarmiest most templated way
to use <string>, <algorithms> etc. to turn this:
" able search baker search charlie "
into this:
" able replace baker replace charlie "
|
by: Steph |
last post by:
Hi.
I'm very new to MS Access and have been presented with an Access database
of contacts by my employer.
I am trying to redesign the main form of the database so that a button
entitled 'search' may be clicked on by the user and the user can then
search all records by postcode. I want to do this to prevent duplicate
data entry.
|
by: James |
last post by:
Why does my LDAP query from a C# console app limit its results to 1000? When
I run the same query from a vb script I get over 6000 results. I have tried
to set the SearchRequest.SizeLimit to a value grater than the expected
results and still only get 1000 records. I did notice that in the
LdapConnection constructor I was required to specify the target server where
in the vbs I simply passed an LDAP query to the ADSDSOObject provider. ...
| |
by: cma2007 |
last post by:
I'm trying to design code that will search for any 10 digit number in an e-mail after pressing the Send button in Microsoft Outlook 2003. I know that simply using the InStr() function would easily perform this if I had a specific string; however, I only want to look for 10 digit numbers. Here is what I'm trying to do:
If InStr(1, Item.Body, TenNumber, vbTextCompare) > 0 Then
<some condition>
However, TenNumber doesn't have a specific...
|
by: JamesOo |
last post by:
I have the code below, but I need to make it searchable in query table,
below code only allowed seach the table which in show mdb only. (i.e. have 3 table, but only can search either one only, cannot serch by combine 3 table)
Example I have the query table below, how do I make the code to seach based on the query from this:
SELECT Product.ID, Product.Description, Quantity.Quantity, Quantity.SeialNo, Quantity.SupplierID,...
|
by: weirdguy |
last post by:
Hello,
Just for anyone information, there is a similar title "Search in Listbox" but it is via Combo Box. In case, anyone need it, I put a link to here.
Please let me know if I break any rules by posting a link so then, I will remove it.
Okay, here is my question. If you ever refer to the link, I am almost doing the same thing. Just that, I am doing a textbox and a combo box to search the listed data in the listbox.
The listbox...
|
by: Debadatta Mishra |
last post by:
Introduction
In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information inside an image, hide your complete image as text ,search for a particular image inside a directory, minimize the size of the image. However this is not a new concept, there is a concept called Steganography which enables to conceal your secret...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |