Solved

display format

Posted on 2011-09-06
4
183 Views
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?
0
Comment
Question by:1jaws
  • 2
  • 2
4 Comments
 
LVL 51

Accepted Solution

by:
HainKurt earned 500 total points
ID: 36493220
try:

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

XXXXXXX7832
0
 
LVL 82

Expert Comment

by:leakim971
ID: 36493231
SELECT LEFT(socsec, LEN(socsec) - 4 ) + RIGHT(socsec,4) FROM yourtable
0
 
LVL 51

Expert Comment

by:HainKurt
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)

78326486324
0
 
LVL 82

Expert Comment

by:leakim971
ID: 36493238
;)
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

770 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