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 |
fmardani
Constraint Violating Yak Guru
433 Posts |
Posted - 2006-12-14 : 07:36:45
|
Hi,Let's assume there is a sting that holds this value:domainName/loginNow I would like to retrieve the login from this string.Could you please let me know if what I am doing is the right way? It does indeed return the correct login string but not sure if this is the preoper way of handling the string in sql.select substring(System_User, patindex('%\%', System_User) + 1, len(System_User))Thanks |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-12-14 : 07:41:27
|
Looks okay, of course you can use CHARINDEX() as well in place of PATINDEX().Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-12-14 : 10:40:52
|
Yes that is the proper way to do in sqlAlso read about parsename in sql server help fileMadhivananFailing to plan is Planning to fail |
 |
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2006-12-14 : 16:43:47
|
SELECT REPLACE(myColumn, LEFT(myColumn, CHARINDEX('/')), '')--Lumbago"Real programmers don't document, if it was hard to write it should be hard to understand" |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-12-14 : 23:27:18
|
quote: Originally posted by Lumbago SELECT REPLACE(myColumn, LEFT(myColumn, CHARINDEX('/')), '')--Lumbago"Real programmers don't document, if it was hard to write it should be hard to understand"
SELECT REPLACE(myColumn, LEFT(myColumn, CHARINDEX('/',mycolumn)), '')MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|