Skip to content

Instantly share code, notes, and snippets.

@ilovejs
Created August 18, 2014 23:52
Show Gist options
  • Save ilovejs/6e0a6563e058eed09898 to your computer and use it in GitHub Desktop.
Save ilovejs/6e0a6563e058eed09898 to your computer and use it in GitHub Desktop.
infoLead database script
select UserA.userID, UserA.userName--, tblLeads.ExhibitionID
from tblUsers as UserA
inner join
(
select count(userID) as noOfDuplicate, userName
from tblUsers
where username like('AGE14S%')
group by userName
having count(userID) > 1
) as DuplicateUser
on UserA.userName = DuplicateUser.userName
/*left outer join tblLeads
on tblLeads.exhibitorID = UserA.UserID*/
begin tran
delete
from [dbo].[juncUserExpo]
where userID in (
'42043',
'42044',
'42045',
'42046',
'42047'
)
commit tran
rollback
begin tran
delete
from tblUsers
where userID in (
select UserID
from tblUsers
where userID not in (
select exhibitorID
from tblLeads
where exhibitionID = '1116'
) and username like('AGE14S%')
)
rollback
begin tran
delete
select *
from tblUsers
where userID not in (
select exhibitorID
from tblLeads
where exhibitionID = '1115'
)
and username like('AGE14S%')
select A.*
from tblUsers A
inner join tblEmails B
on A.userID = B.ExhibitorID
inner join tblLeads C
on A.userID = C.exhibitorID
where A.username like('AGE14S%')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment