Solved

display format

Posted on 2011-09-06
4
185 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:
Huseyin KAHRAMAN 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:Huseyin KAHRAMAN
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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS SQL GROUP BY 6 70
SQL Query incorrect syntax near the keyword ON any help would be appreciated 18 27
SSMS Imprt data from Excel 7 19
Need help with a query 14 32
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

679 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