display format

Posted on 2011-09-06
Last Modified: 2012-05-12
trying to display the soc. sec number on this format xxxxxxx1234  just the last four will show and front will show all xxx 's  .. how can I do that in tsql in my query?
Question by:1jaws
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 56

Accepted Solution

HainKurt earned 500 total points
ID: 36493220

declare @soc_number varchar(11) = '78326486324';
select right('XXXXXXXXXXX' + left(@soc_number,4),11)

LVL 82

Expert Comment

ID: 36493231
SELECT LEFT(socsec, LEN(socsec) - 4 ) + RIGHT(socsec,4) FROM yourtable
LVL 56

Expert Comment

ID: 36493235
leakim971, you need some coffee :)

declare @soc_number varchar(11) = '78326486324';
SELECT LEFT(@soc_number, LEN(@soc_number) - 4 ) + RIGHT(@soc_number,4)

LVL 82

Expert Comment

ID: 36493238

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor ( Top Charts is a view in which you can set seve…

623 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