Hi,
I have on NCHAR column which has value like.. 1:25:234567. I have to
extract last part of value i. e. 234567 which comes after sign ':' .
The no. of digits vary. How can i do that using TSQL .
Please Help !!
Thanks
NJneeju a crit :
> Hi,
> I have on NCHAR column which has value like.. 1:25:234567. I have to
> extract last part of value i. e. 234567 which comes after sign ':' .
> The no. of digits vary. How can i do that using TSQL .
> Please Help !!
> Thanks
> NJ
>
SELECT REVERSE(SUBSTRING(REVERSE('1:25:234567')
, 1, CHARINDEX(':',
REVERSE('1:25:234567'))-1))
More generally :
SELECT REVERSE(SUBSTRING(REVERSE(MyColumn), 1, CHARINDEX(':',
REVERSE(MyColumn))-1))
A +
Frdric BROUARD, MVP SQL Server, expert bases de donnes et langage SQL
Le site sur le langage SQL et les SGBDR : http://sqlpro.developpez.com
Audit, conseil, expertise, formation, modlisation, tuning, optimisation
********************* http://www.datasapiens.com ***********************|||Oh Thanks a lot...that worked after small change..
Thanks again
NJ
No comments:
Post a Comment