If not exists (select 1 from tempdb
if not exists (select 1 from tempdb..sysobjects
where type = 'U' and name = 'DBA_syslogins')
create table tempdb..DBA_syslogins
(name sysname not null primary key)
go
declare @body varchar(8000)
set @body = 'New logins: '
-- If it's not the first time it executes:
if exists (select 1 from tempdb..DBA_syslogins)
begin
-- If there are any new logins:
if exists (select 1 from master..syslogins
where name not in
(select name from tempdb..DBA_syslogins))
begin
select @body = @body + name + ','
from master..syslogins
where name not in (select name from tempdb..DBA_syslogins)
-- Omit the last comma:
select @body = substring(@body,1,LEN(@body)-1)
-- Send the message to the DBA with new logins:
EXEC msdb.dbo.sp_send_dbmail
@recipients=N'michelle.gutzait@Adventure-',
@body=N'New logins have been created.'
end
end
-- Modify the table’s content anyway
-- (since we’re not checking for deleted logins):
truncate table tempdb..DBA_syslogins
insert into tempdb..DBA_syslogins (name)
select name from master..syslogins
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- ejercicios realización de consultas sql
- processing big data with azure data lake
- extension to sql view triggers cursor
- sql overview and highlights
- chapter 8 advanced sql
- m y s q l b y e x a m p l e s f o r b e g i n n e r s
- sql server alwayson errors related to availability groups
- if not exists select 1 from tempdb
- sql server and oracle
- about this document
Related searches
- mkdir if not exists python
- create database if not exists postgres
- create database if not exists sql
- if not exists create table sql server
- create if not exists sql
- if not exists create view
- 5 or 276 select 276 from pg sleep 15 168 1 1 default username and password
- 5 or 346 select 346 from pg sleep 15 168 1 1 admin username and password
- 5 or 891 select 891 from pg sleep 15 168 1 1 admin username and password
- 192 5 or 62 select 62 from pg sleep 15 1 1 default username and password
- 1 or 781 select 781 from pg sleep 15 168 1 1 admin username and password
- 192 5 or 35 select 35 from pg sleep 15 1 1 default username and password