I am trying to get the folder name from the v_R_User.HomeDirectory0 without the 
full path. For instance I have 
\\servername\sharename\jsmith<file:///\\servername\sharename\jsmith> and I just 
wanna see jsmith.

In my Select statement I tried

SUBSTRING(v_R_user.homeDirectory0, CHARINDEX('\', v_R_user.homeDirectory0) + 1, 
LEN(v_R_user.homeDirectory0)) AS [Home Folder]


But I still get the entire folder path. What should I change?


Here's the entire query:


SELECT DISTINCT

v_r_system_valid.Netbios_Name0 AS [Computer Name],

v_r_system_valid.User_Name0 AS [User Name],

v_R_User.homeDirectory0 as [Home Directory],

SUBSTRING(v_R_user.homeDirectory0, CHARINDEX('\', v_R_user.homeDirectory0) + 1, 
LEN(v_R_user.homeDirectory0)) AS [Home Folder],

v_R_User.Full_User_Name0 AS [Full User Name],

v_R_User.department0 AS [Dept]



 FROM

v_R_System_valid

 join

 v_R_user on (v_R_user.user_name0 = 
substring(v_R_System_Valid.user_name0,charindex('\',v_R_System_Valid.user_name0)+1,len(v_R_System_Valid.user_name0)))


________________________________
John Marcum
Sr. Desktop Architect
Bradley Arant Boult Cummings LLP
________________________________


________________________________

Confidentiality Notice: This e-mail is from a law firm and may be protected by 
the attorney-client or work product privileges. If you have received this 
message in error, please notify the sender by replying to this e-mail and then 
delete it from your computer.


Reply via email to