Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一张包含所有员工详细信息的表格,包括电子邮件地址
在遇到字母“@”之前,是否有任何特定查询可以找到电子邮件地址的长度?
如果电子邮件地址是 azxcde@asas.com,那么我想提取电子邮件的 azxcde 部分。
Select Left(EmailColumnName,CharIndex('@',EmailColumnName)-1) as UserName from tableName
SQL 小提琴演示
这是使用 SUBSTRING 的替代版本:
SELECT SUBSTRING(EmailColumnName,0,CHARINDEX(' ',EmailColumnName)) as UserName FROM tablName