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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-06-07 : 08:22:29
|
| Mike writes "Hello,I have a SQL 7.0 database that logs web usage. On of the fields in the tableis clientusername and it logs domain\username. I would like to create a viewthat selects from clientusername and only display username without the domain.In MS Access I can use: Select Mid([clientusername],5) and this will drop our domain name includingthe \. How can I do this in SQL?I need to extract the username so that I can e-mail the usage reports tothe user by appending the @domain.com to the end of their name.Thank You " |
|
|
dataphile
Yak Posting Veteran
71 Posts |
Posted - 2002-06-07 : 08:35:04
|
| Play with this to learn the concept:select substring('user\domain',1,charindex('\','user\domain',1)-1)+'@'+substring('user\domain',charindex('\','user\domain',1)+1,len('user\domain'))then :create view ViewName asselect substring(fieldname,1,charindex('\',fieldname,1)-1)+'@'+substring(fieldname,charindex('\',fieldname,1)+1,len(fieldname))from tablenameEdited by - dataphile on 06/07/2002 08:37:18 |
 |
|
|
|
|
|
|
|