| Author |
Topic  |
|
|
divan
Posting Yak Master
125 Posts |
Posted - 01/08/2013 : 08:26:05
|
I have a table where there is a column Name Description Code and TBName when I run the following script
Select * from edit_long_code I get for example
Name Description Code TBname LIAB_LMT $100,000 / $300,000 001 AAC_DETAIL
Is there a way I can display the description into $100,000 and $300,000 separately when I try to write a report script?
|
|
|
nigelrivett
Flowing Fount of Yak Knowledge
United Kingdom
3328 Posts |
Posted - 01/08/2013 : 08:31:01
|
select left(description,charindex('/',description)), right(description,charindex('/',reverse(description))) from tbl
You'll probably have to subtract/add a couple to the lengths.
========================================== Cursors are useful if you don't know sql. SSIS can be used in a similar way. Beer is not cold and it isn't fizzy. |
 |
|
|
divan
Posting Yak Master
125 Posts |
Posted - 01/08/2013 : 08:37:09
|
Thanks Nigelrivett your suggestion worked and I get the following result
$100,000 / / $300,000
is there anyway to get rid of the / in the display and just display
$100,000 $300,000
|
 |
|
|
bandi
Flowing Fount of Yak Knowledge
India
1451 Posts |
Posted - 01/08/2013 : 08:56:01
|
left(description,charindex('/',description)-1), right(description,charindex('/',reverse(description))-1)
-- Chandu |
 |
|
|
Jeff Moden
Aged Yak Warrior
USA
643 Posts |
Posted - 01/14/2013 : 23:35:16
|
quote: Originally posted by divan
Thanks Nigelrivett your suggestion worked and I get the following result
$100,000 / / $300,000
is there anyway to get rid of the / in the display and just display
$100,000 $300,000
Did you lookup CHARINDEX and REVERSE in Books Online to see how this works or are you just going to use it as a black box?
--Jeff Moden RBAR is pronounced "ree-bar" and is a "Modenism" for "Row By Agonizing Row".
First step towards the paradigm shift of writing Set Based code: "Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
When writing schedules, keep the following in mind: "If you want it real bad, that's the way you'll likely get it." |
 |
|
| |
Topic  |
|
|
|