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 |
divan
Posting Yak Master
153 Posts |
Posted - 2013-01-08 : 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 TBnameLIAB_LMT $100,000 / $300,000 001 AAC_DETAILIs there a way I can display the description into $100,000 and $300,000 separately when I try to write a report script? |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2013-01-08 : 08:31:01
|
select left(description,charindex('/',description)), right(description,charindex('/',reverse(description)))from tblYou'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
153 Posts |
Posted - 2013-01-08 : 08:37:09
|
Thanks Nigelrivett your suggestion worked and I get the following result $100,000 / / $300,000is there anyway to get rid of the / in the display and just display $100,000 $300,000 |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-01-08 : 08:56:01
|
left(description,charindex('/',description)-1), right(description,charindex('/',reverse(description))-1)--Chandu |
|
|
Jeff Moden
Aged Yak Warrior
652 Posts |
Posted - 2013-01-14 : 23:35:16
|
quote: Originally posted by divan Thanks Nigelrivett your suggestion worked and I get the following result $100,000 / / $300,000is 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." |
|
|
|
|
|
|
|