Replace numbers with asterisks

Hi,

I want to replace the first all the numbers of 15 characters of a 19 digit number with asterisks. Is this possible using a SQL command?

Thanks.

input: 1234 3456 7890 1234
result: **** **** **** 1234

Open in new window

egxisAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MilleniumaireCommented:
Use the substring function as part of an update e.g.

update table
set col = '***************' + substr(col,16,4)
0
MilleniumaireCommented:
Sorry, the substr function is called substring in SQL Server, not substr.  I was thinking with my Oracle hat on!

You may be able to omit the 3rd option (4 in the example) to give all characters to the end of the string.  This is valid in Oracle, but not sure about SQL Server.
0
dqmqCommented:
select '**** **** **** ' + right(YourField,4)
0
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

mfsamuelCommented:
Try this.
SELECT '**** **** **** '+SUBSTRING(input, 16, 4)
FROM table_name

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mfsamuelCommented:
we all answered basically the same within seconds it seems. :)
0
egxisAuthor Commented:
Wow - that was quick. This is a tough one as you all answered similarly, but techncally mfsamuel was most correct.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.