Question

In: Computer Science

I need to show this using SQL: Credit card numbers should include asterisks in place of...

I need to show this using SQL: Credit card numbers should include asterisks in place of all digits preceding the last four digits, which will be left visible, regardless of credit card length

Solutions

Expert Solution

As you have not shared your tabel schema here is my attempt to create one and take some action.

BEGIN TRANSACTION;

drop table card;
create table card(number varcar, name varchar);
insert into card (number, name) values ('12345678901234', 'abc') ;
insert into card (number, name) values ('12346678908907', 'pqr');
insert into card (number, name) values ('11111111111934', 'xyz');
COMMIT;

CREATE FUNCTION [dbo].[hideCardNumber](@InputString varchar(card))
RETURNS VARCHAR(card)
AS
BEGIN
declare @len int
,@Counter int
,@OneChar char(1)
set @Counter = 1
set @len = LEN(@card);
while (1 = 1)
begin
set @OneChar = SUBSTRING(@InputString, @Counter, 1)
set @InputString = REPLACE(@InputString, @OneChar, '*')
set @Counter = @Counter + 1

if (
@Counter > @len - 4
)
break;
end

return @InputString
END


select * from card;

select dbo.hideCardNumber(number) as num from card;


Related Solutions

I need java code for this ..thx Question 2 Credit card numbers are not completely random...
I need java code for this ..thx Question 2 Credit card numbers are not completely random sequences; they follow certain rules depending on the card issuer. A MasterCard number must meet these criteria: • Begin with 51, 52, 53, 54, 55, or something in the range 222100-272099 • 16 digits in length • Satisfy the Luhn formula, created by IBM scientist Hans Peter Luhn in the 1950s Here’s how the Luhn formula works: Double every other digit going backwards, starting...
I am working on an assignment using SQL Server Management and I need to print an...
I am working on an assignment using SQL Server Management and I need to print an ERD to a single page as a PDF file. I am not sure how to do this especially because the diagram is rather large... I am using SQL Server Management Studio I have created an Entity relationship diagram for AdventureWorks that includes all product tables. There are many tables.How do I print it to a single page?
I need step by step to know where is my mistake ? Account Name: Credit Card...
I need step by step to know where is my mistake ? Account Name: Credit Card – Visa $0 November 30, 2021 Checking - Raincross Business Bank 4673 $13,000 November 30, 2021 Savings - Raincross Business Bank$5,000 November 30, 2021 Display your trial balance report for 12/01/2021 Wednesday, December 1, 2021 •Received cash from Dan Greany for Hand Wash with Interior and Electronic Odor Elimination services, using Sales Receipt number 21-102. (Remember to deposit to Undeposited Funds.) •Received check number...
I need a brief summary/your thoughts on the article. The long-standing narrative of credit card security...
I need a brief summary/your thoughts on the article. The long-standing narrative of credit card security is that offline transactions are more secure than online. Today, this narrative is more fiction than fact. Online transactions are more popular and secure than ever before, thanks to advancements in digital payments technology, demographic shifts, and the evolving cyber-security landscape. At the same time, offline payments seem more insecure than ever before. The outbreak of high-profile security breaches at major retailers has shed...
I just applied for a credit card from Lowe’s (“hardware stores – only things you need,...
I just applied for a credit card from Lowe’s (“hardware stores – only things you need, nothing you want.”) and the APR is 24.99% with monthly payments (I am not kidding). What is the EAR on this credit card? If you have a balance of $7,500 and make minimum payments of $350 a month, how many months until this card is paid off? Bond Gold has a coupon rate of 4.3 percent. Bond Griff has a coupon rate of 14.3...
Need SQL Tables Final Project should be included ER, NER, Table diagrams and SQL statements. The...
Need SQL Tables Final Project should be included ER, NER, Table diagrams and SQL statements. The final project is about developing an auction Web site. The details are as follows: BA is an online auction Web site. People can buy and sell items in this Web site. Buyers are people who like to buy items, and sellers are people who like to sell items. •Each seller can sell items. •Each item has a bidding start time, an end time, and...
Many types of identification numbers, including credit card numbers, must satisfy the Luhn Algorithm in order...
Many types of identification numbers, including credit card numbers, must satisfy the Luhn Algorithm in order to be considered "valid". This algorithm verifies the number by performing the following operation: starting from the right-most digit, double every 2nd digit. If this doubling causes that digit to be greater than 9, subtract 9 from it. Now add up all the new digits of the number (including the digits that weren't doubled). If the sum is evenly divisible by 10, then the...
Part I – Consumer Credit Gregg is planning to apply for a new credit card and...
Part I – Consumer Credit Gregg is planning to apply for a new credit card and is considering the following three choices. He is also planning to buy a $500 big screen television and plans to pay for this over a two-year period by making equal monthly. Credit Card Annual Interest Rate Annual Fee MBNA True Line Master Card 8.99% $39 Desjardins Classic Visa 12.90% $30 American Express Essential Credit Card 12.99% $0 Question 71 What would be his monthly...
show all calculation Suppose Alex could borrow using either a credit card that charges 1 percent...
show all calculation Suppose Alex could borrow using either a credit card that charges 1 percent per month or a bank loan with a 12 percent quoted interest rate that is compounded daily. Which one should she choose?
DBMS Create/Insert/Update SQL I need the create, insert, and update SQL statement for this table: Customer...
DBMS Create/Insert/Update SQL I need the create, insert, and update SQL statement for this table: Customer PK Customer ID Text Phone Number int name text address ID int email text FK vendor ID int Vendor is the name of the table the FK comes from.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT