Just use one combined search string, like
select *
from yourTable
where empmailid like '%@%.%'
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi I have one dobut in sql server .
how to check 2 conditions qualified or not in emailid
first check @ symbole is available or not if its available after @ next .(dot) symbole is availablero not
if both conditions satisfied then reterive those records .
CREATE TABLE [dbo].empdetails
INSERT [dbo].[empdetails] ([empid], [empmailid], [sal]) VALUES (1, N'abc.g@Stuff .com', 100)
INSERT [dbo].[empdetails] ([empid], [empmailid], [sal]) VALUES (2, N'hari.@Stuff ', 200)
INSERT [dbo].[empdetails] ([empid], [empmailid], [sal]) VALUES (3, N'vani@Stuff .com', 300)
INSERT [dbo].[empdetails] ([empid], [empmailid], [sal]) VALUES (4, N'ravi.kishor@réalisations .in', 400)
INSERT [dbo].[empdetails] ([empid], [empmailid], [sal]) VALUES (5, N'har.pan@Stuff .com', 500)
INSERT [dbo].[empdetails] ([empid], [empmailid], [sal]) VALUES (6, N'hanithanu.ra', 600)
based on above data I want output like below :
empid |empmailid |sal
1 |abc.g@Stuff .com |100
3 |vani@Stuff .com |300
4 |ravi.kishor@réalisations .in|400
5 |har.pan@Stuff .com |500
I have tried like below .
SELECT [empid]
,[empmailid]
,[sal]
FROM [test123].[dbo].[empdetails]
where empmailid like '%@%' and empmailid like'.'
above query not given expected result .
please tell me how to write query to achive this task in sql server
Just use one combined search string, like
select *
from yourTable
where empmailid like '%@%.%'
Try this:
SELECT [empid]
,[empmailid]
,[sal]
FROM [dbo].[empdetails]
where empmailid like '%@%' and charindex('.', empmailid,(charindex('@', empmailid, 1)))>0
Bert Zhou