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 |
|
yguvvala
Starting Member
2 Posts |
Posted - 2012-06-28 : 12:41:35
|
| Hi,I am new to SQL i have a coloumn with records having lots of information in it i need to extract a perticular data from it how can i do it.values form the coloumn are as follows and i need to extract bold number from teh records and column name is status :STATUS=APPROVED!!TASK=<1221>!!AUDITID=<9219767>!!APPROVER=<153061>!!STATUS=APPROVED!!TASK=<1221>!!AUDITID=<9219975>!!APPROVER=<160502>!!STATUS=APPROVED!!TASK=<1221>!!AUDITID=<9219992>!!APPROVER=<49016>!!STATUS=APPROVED!!TASK=<1221>!!AUDITID=<9220128>!!APPROVER=<38520>!!STATUS=APPROVED!!TASK=<1221>!!AUDITID=<9220125>!!APPROVER=<38520>!!STATUS=APPROVED!!TASK=<1221>!!AUDITID=<9220160>!!APPROVER=<45784>!!STATUS=APPROVED!!TASK=<1221>!!AUDITID=<9220266>!!APPROVER=<160502>!!STATUS=APPROVED!!TASK=<1221>!!AUDITID=<9220271>!!APPROVER=<153061>!!Thanks,Yguvvala |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-06-28 : 12:54:51
|
| select substring(str, charindex('!!AUDITID=<', str)+len('!!AUDITID=<'), charindex('>!!APPROVER',str)-(charindex('!!AUDITID=<', str)+len('!!AUDITID=<')))frrom tbl==========================================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. |
 |
|
|
xhostx
Constraint Violating Yak Guru
277 Posts |
Posted - 2012-06-28 : 13:12:09
|
quote: Originally posted by yguvvala Hi,I am new to SQL i have a coloumn with records having lots of information in it i need to extract a perticular data from it how can i do it.values form the coloumn are as follows and i need to extract bold number from teh records and column name is status :STATUS=APPROVED!!TASK=<1221>!!AUDITID=<9219767>!!APPROVER=<153061>!!STATUS=APPROVED!!TASK=<1221>!!AUDITID=<9219975>!!APPROVER=<160502>!!STATUS=APPROVED!!TASK=<1221>!!AUDITID=<9219992>!!APPROVER=<49016>!!STATUS=APPROVED!!TASK=<1221>!!AUDITID=<9220128>!!APPROVER=<38520>!!STATUS=APPROVED!!TASK=<1221>!!AUDITID=<9220125>!!APPROVER=<38520>!!STATUS=APPROVED!!TASK=<1221>!!AUDITID=<9220160>!!APPROVER=<45784>!!STATUS=APPROVED!!TASK=<1221>!!AUDITID=<9220266>!!APPROVER=<160502>!!STATUS=APPROVED!!TASK=<1221>!!AUDITID=<9220271>!!APPROVER=<153061>!!select substring('STATUS=APPROVED!!TASK=<1221>!!AUDITID=<9219767>!!APPROVER=<153061>!!', patindex('%AUDITID=<%','STATUS=APPROVED!!TASK=<1221>!!AUDITID=<9219767>!!APPROVER=<153061>!!')+len('AUDITID=<'),patindex('%>!!APPROVER%', 'STATUS=APPROVED!!TASK=<1221>!!AUDITID=<9219767>!!APPROVER=<153061>!!')- (patindex('%AUDITID=<%','STATUS=APPROVED!!TASK=<1221>!!AUDITID=<9219767>!!APPROVER=<153061>!!')+len('AUDITID=<')))replace the string with column's nameThanks,Yguvvala
--------------------------Get rich or die trying-------------------------- |
 |
|
|
yguvvala
Starting Member
2 Posts |
Posted - 2012-06-28 : 16:18:09
|
it works thankyou ..... |
 |
|
|
|
|
|
|
|