Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
itnagaraj
Yak Posting Veteran
70 Posts |
Posted - 2013-12-16 : 06:23:20
|
In DB, The Value is like belowSSN---46894789456784567 467897789048561234789564678Output need like below.----------------------XXX XX 4689XXX XX 4789456 78 4567 467 89 7789048 56 1234789 56 4678How can we write the query in Sql.V.NAGARAJAN |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-12-16 : 06:27:25
|
[code]SELECT SSN, STUFF(STUFF(COALESCE(REPLICATE('X',9-LEN(SSN)),'') + SSN,4,0,' '),7,0,' ') AS ModifiedFROM Table[/code]Change it into an update if you want change to be applied to table as well------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
itnagaraj
Yak Posting Veteran
70 Posts |
Posted - 2013-12-16 : 06:29:57
|
Thank you very much.quote: Originally posted by visakh16
SELECT SSN, STUFF(STUFF(COALESCE(REPLICATE('X',9-LEN(SSN)),'') + SSN,4,0,' '),7,0,' ') AS ModifiedFROM Table Change it into an update if you want change to be applied to table as well------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs
V.NAGARAJAN |
|
|
|
|
|
|
|