Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
select charindex('15425','order number #15425') - returns 15and i want output - 15425means i have 30 rows -select orderid, charindex('Order number #',ordnum) as ord from orders will returns 30 different values.. in ord column...i want to use case statement in itlike -select orderid, case when charindex('Order number #',ordnum) then [value after '#' sign and the length of that values are 7 ]what should come after then ?it should be return value whatever it will be there after '#' sign - 7digit...output will beorderid ord--------------100 1253245123 415-512124 15-1521any idea?thanks.
sodeep
Master Smack Fu Yak Hacker
7174 Posts
Posted - 2009-01-15 : 15:10:42
Do you mean this?
Select orderid,substring(ordnum,Charindex('#',ordnum)+1,7)as ord from table
khusiie
Yak Posting Veteran
78 Posts
Posted - 2009-01-15 : 15:15:00
excellent!!!!!!!!!thanks a ton!!! i appreciate it!!!! Thanks