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.
Hai friends, I have the IP address stored in DB in the following formatIN:192.22.22.22:1968from this string i need to find only the IP address...Sometimes i maynot have the Port address ie, last four digit...to find the first 3 charatcters i can use charindex('IN:',string)..but to find the last four characters, i dont know how to do..help pls
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts
Posted - 2006-04-15 : 01:43:31
Somthing like this ..
Declare @Tmp Table (Ip_Add Varchar(20))Insert @Tmp Select '192.22.22.22:1968' Union All Select '192.22.22.22' Union All Select '192.22.22.22:808'Union All Select '192.22.22.2'Select Replace(Ip_Add,SubString(Ip_Add,CharIndex(':',Ip_Add),Len(Ip_Add)),'') From @Tmp Where CharIndex(':',Ip_Add)>0
If Debugging is the process of removing Bugs then i Guess programming should be process of Adding them.
madhivanan
Premature Yak Congratulator
22864 Posts
Posted - 2006-04-17 : 02:24:05
orselect left(Ip_Add, charindex(':',Ip_add,1)-1) from @tmpWhere CharIndex(':',Ip_Add)>0MadhivananFailing to plan is Planning to fail