Skip to content

Commit 80d5bf5

Browse files
committed
sql samples
1 parent 356da36 commit 80d5bf5

388 files changed

Lines changed: 7343 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-- =============================================
2+
-- Create Aggregate Template
3+
-- =============================================
4+
IF EXISTS(
5+
SELECT *
6+
FROM sys.objects
7+
WHERE name = N'<aggregate_name, sysname, sample_aggregate>'
8+
AND (type = 'AF')
9+
)
10+
DROP AGGREGATE <aggregate_name, sysname, sample_aggregate>
11+
GO
12+
13+
CREATE AGGREGATE <aggregate_name, sysname, sample_aggregate>(@<parameter_name, sysname, parameter1> <parameter_type, sysname, nvarchar(4000)>)
14+
RETURNS <return_type, sysname, nvarchar(4000)>
15+
EXTERNAL NAME <assembly_name, sysname, sample_assembly>.<clr_type_name, sysname, sample_clr_name>
16+
GO
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-- =============================================
2+
-- Drop Aggregate Template
3+
-- =============================================
4+
IF EXISTS(
5+
SELECT *
6+
FROM sys.objects
7+
WHERE name = N'<aggregate_name, sysname, test_agg>'
8+
AND (type = 'AF')
9+
)
10+
DROP AGGREGATE <aggregate_name, sysname, test_agg>
11+
GO
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--=============================================================
2+
-- Create Assembly Template
3+
--=============================================================
4+
IF EXISTS(
5+
SELECT *
6+
FROM sys.assemblies
7+
WHERE name = N'<assembly_name, SYSNAME, MyClass>'
8+
)
9+
DROP ASSEMBLY <assembly_name, SYSNAME, MyClass>;
10+
GO
11+
12+
CREATE ASSEMBLY <assembly_name, SYSNAME, MyClass>
13+
FROM N'<Assembly_DLL_Name, nvarchar(4000), Path_MyAssembly.dll>'
14+
WITH PERMISSION_SET = <Safe_External_Access_Unsafe, , SAFE>;
15+
GO
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--=============================================================
2+
-- Drop Assembly Template
3+
--=============================================================
4+
IF EXISTS(
5+
SELECT *
6+
FROM sys.assemblies
7+
WHERE name = N'<assembly_name, SYSNAME, MyClass>'
8+
)
9+
DROP ASSEMBLY <assembly_name, SYSNAME, MyClass>
10+
11+
12+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-- =============================================
2+
-- Alter Database Audit Specification Template
3+
-- =============================================
4+
5+
-- =============================================
6+
-- Author: <Author,,>
7+
-- Create date: <Create Date,,>
8+
-- Description: <Description,,>
9+
-- =============================================
10+
ALTER DATABASE AUDIT SPECIFICATION <audit_specification_name,nvarchar,audit_specification_name>
11+
FOR SERVER AUDIT <audit_name,nvarchar,audit_name>
12+
DROP (SELECT on <object,nvarchar,table1> BY <principal, nvarchar, user1>)
13+
ADD (INSERT on <object,nvarchar,table1> BY <principal, nvarchar, user1>)
14+
WITH ( STATE = <state,bool,OFF > )
15+
16+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-- =============================================
2+
-- Alter Server Audit Specification Template
3+
-- =============================================
4+
5+
-- =============================================
6+
-- Author: <Author,,>
7+
-- Create date: <Create Date,,>
8+
-- Description: <Description,,>
9+
-- =============================================
10+
ALTER SERVER AUDIT SPECIFICATION <audit_specification_name,nvarchar,audit_specification_name>
11+
FOR SERVER AUDIT <audit_name,nvarchar,audit_name>
12+
DROP(<audit_action_group_name,name,FAILED_LOGIN_GROUP>)
13+
ADD (<audit_action_group_name,name,SUCCESSFUL_LOGIN_GROUP>)
14+
WITH ( STATE = <state,bool,OFF > )
15+
16+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-- =============================================
2+
-- Alter Server Audit Template
3+
-- =============================================
4+
5+
-- =============================================
6+
-- Author: <Author,,>
7+
-- Create date: <Create Date,,>
8+
-- Description: <Description,,>
9+
-- =============================================
10+
ALTER SERVER AUDIT <audit_name,nvarchar,AUDIT_NAME>
11+
TO FILE(FILEPATH = <filepath,nvarchar,N'file_path'>,
12+
MAXSIZE=<size,integer,2147483647>,
13+
MAX_ROLLOVER_FILES =<files,integer,0>,
14+
RESERVE_DISK_SPACE =<reserve_disk_space,bool,OFF>)
15+
WITH (QUEUE_DELAY = <milliseconds,integer,1000>,
16+
ON_FAILURE = <On_failure,,SHUTDOWN> )
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
-- =============================================
2+
-- Create Database Audit Specification Template
3+
-- =============================================
4+
5+
-- =============================================
6+
-- Author: <Author,,>
7+
-- Create date: <Create Date,,>
8+
-- Description: <Description,,>
9+
-- =============================================
10+
CREATE DATABASE AUDIT SPECIFICATION <audit_specification_name,nvarchar,audit_specification_name>
11+
FOR SERVER AUDIT <audit_name,nvarchar,audit_name>
12+
ADD (SELECT on <object,nvarchar,table1>BY <principal, nvarchar,user1>) WITH ( STATE = <state,bool,OFF > )
13+
14+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
-- =============================================
2+
-- Create Server Audit Specification Template
3+
-- =============================================
4+
5+
-- =============================================
6+
-- Author: <Author,,>
7+
-- Create date: <Create Date,,>
8+
-- Description: <Description,,>
9+
-- =============================================
10+
CREATE SERVER AUDIT SPECIFICATION <audit_specification_name,nvarchar,audit_specification_name>
11+
FOR SERVER AUDIT <audit_name,nvarchar,audit_name>
12+
ADD (<audit_action_group_name,sysname,FAILED_LOGIN_GROUP> )
13+
WITH ( STATE = <state,bool,OFF > )
14+
15+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-- =============================================
2+
-- Create Server Audit Template
3+
-- =============================================
4+
5+
-- =============================================
6+
-- Author: <Author,,>
7+
-- Create date: <Create Date,,>
8+
-- Description: <Description,,>
9+
-- =============================================
10+
CREATE SERVER AUDIT audit_name
11+
TO FILE (FILEPATH = <filepath,nVarChar,N'file_path'>,
12+
MAXSIZE=<size,integer,2147483647 >,
13+
MAX_ROLLOVER_FILES =<files,integer,0>,
14+
RESERVE_DISK_SPACE =<reserve_disk_space,bool,OFF>)
15+
WITH (QUEUE_DELAY = <milliseconds,integer,1000>,
16+
ON_FAILURE = <On_failure,,SHUTDOWN> )

0 commit comments

Comments
 (0)