SQL Stmt


I have a user_name column in access with the following sample data.

John Smith (JSMITH)
Thomas Edison (TEDISON)

I need a SQL gives me the following output.


Please suggest.
Who is Participating?
mbizupConnect With a Mentor Commented:
Try this:

SELECT Mid([User_Name], instr(1,[User_Name],"(") + 1 ,instr(1,[User_Name],")") - instr(1,[User_Name],"(") - 1)  AS NewColumn
FROM YourTable

Open in new window

winheimConnect With a Mentor Commented:
here a sample if you do not need it from a table

* Define the Value you would like to split
DECLARE @s nvarchar(100)
SET @s =  'John Smith (JSMITH)'

* declare the split token
DECLARE @sSplitPoint nvarchar(100)
SET @sSplitPoint = ' ('

* Find the position of the split token
DECLARE @iStartToSpilt int
SET @iStartToSpilt = CHARINDEX(@sSplitPoint ,@s) + Len(@sSplitPoint)

* use the substring function to split the string based on the found split token position 

SELECT substring(@s,@iStartToSpilt, Len(@s) - @iStartToSpilt)

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.