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 |
KabirPatel
Yak Posting Veteran
54 Posts |
Posted - 2008-05-09 : 07:18:17
|
Hi,I have a table as follows:UserID FirstName LastName [ID]-----------------------------------------ID1 TestF1 TestL1 1ID2 TestF2 TestL2 2ID3 TestF3 TestL3 3I would like to output the data as follows:X_J001 | TestF1 | TestL1 X_J002 | TestF2 | TestL2X_J003 | TestF3 | TestL3where the first field is the concatenation of "X_J" followed by the formatting of the [ID] column with leading zeros when appropriate.How do I do this?Thanks in advanceKabir |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-05-09 : 07:28:29
|
[code]select 'X_J' + right('00' + replace(UserID, 'ID', ''), 3), FirstName, LastName from Table[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
|
|