Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7523183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:43:20+00:00 2026-05-30T02:43:20+00:00

In each column, after first 5 characters I need to add/replace next 5 characters

  • 0

In each column, after first 5 characters I need to add/replace next 5 characters with ‘*’ then add 10 more white spaces.

SELECT nameFirst, nameLast, number, fax 
FROM table_01

Expected result:-

Revol*****          Jenni*****          598-1*****          12345*****      
Jenit*****          Austi*****          598-1*****          12345*****          
Revol*****          Jenni*****          598-1*****          12345*****

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T02:43:22+00:00Added an answer on May 30, 2026 at 2:43 am

    This should do it.

    SELECT 
       LEFT(nameFirst,5) + '*****          ',
       LEFT(nameLast,5) + '*****          ',
       LEFT(number,5) + '*****          ',
       LEFT(fax ,5) + '*****          '
    FROM table_01
    

    If you think you might want to use a variable later for the number of * and space characters, this technique might be better (and more readable) but uses keywords that are specific to tSQL:

    SELECT 
       LEFT(nameFirst,5) + REPLICATE('*',5) + SPACE(10),
       LEFT(nameLast,5) + REPLICATE('*',5) + SPACE(10),
       LEFT(number,5) + REPLICATE('*',5) + SPACE(10),
       LEFT(fax ,5) + REPLICATE('*',5) + SPACE(10)
    FROM table_01
    

    Update per your comment
    Assuming you want extra *’s for names with <5 characters. Here is an approach that should work.

    SELECT 
       LEFT(nameFirst + replicate('*',5),5) + replicate('*',5) + SPACE(10)
       ...
    FROM table_01
    

    It is a little sneaky, but it avoids a longer inline conditional.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a query that will return a table where each column is the
I want to insert a comma after the first column and as well as
Does each column of a table in SQL Server have a unique id? I've
I have a DataGrid where each column has a SortExpression. I would like the
I've a table with 2 columns and each column is 800px wide. I want
I am trying to transform my data.frame by calculating the log-differences of each column
I have a problem with a data-bound DataGrid control, in that despite each column
I have a DataRow with columns col1 and col2. Each column has a value:
I'm binding a datatable to a gridview control, and when I format each column
According to the sqlite3 documentation , The COLLATE clause following each column name defines

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.