Jignesh Shah
Jignesh Shah

Reputation: 17

SQL server T-SQL statement

I have one table its name - UserData and its contain one column name -
UserInfo.

UserInfo column contains following values likes

demo.acc.in

swiss.com.au

austa.edu.co

I want to extract the following information from it...

Output

 demo
 swiss
 austa

Thanks in advance for help

Upvotes: 0

Views: 42

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1270421

You can use left() and charindex():

select left(userinfo, charindex('.', userinfo + '.') - 1)

Note that the + '.' means that this will work even when userinfo does not contain a space.

Upvotes: 5

Related Questions