0

Hi,
I have a table field with var char data type having values like TVM/345/2000,TVM/01/00,TSR/42/01 etc.I want to extract the sub string from first location to the second '/' location as TVM/345/.
Is there any built in function to solve is?

Thanks

2
Contributors
4
Replies
6
Views
6 Years
Discussion Span
Last Post by divyakrishnan
0

SYNTAX

select substring(COLNAME, 1, CHARINDEX('/',COLNAME, CHARINDEX('/',COLNAME)+1)) FROM TABLENAME

EXAMPLE

select substring('TVM/345/2000,TVM/01/00,TSR/42/01', 1,CHARINDEX('/','TVM/345/2000,TVM/01/00,TSR/42/01',CHARINDEX('/','TVM/345/2000,TVM/01/00,TSR/42/01')+1))
0

Thank You Very much..
There is one more thing I want to do.
Can I update the fields like TVM/01/00 as TVM/01/2000?

0

before running this query keep backup of that column. or do it in dummy database

update tablename set colname=replace(colname,'TVM/01/00','TVM/01/2000')

Edited by urtrivedi: n/a

0

It is not like that.The field is a dynamic field..I got the solution..Thanks for your support...

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.