-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
1,033 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
...osoft SQL Server Management Studio/Code Snippets/SQL/My Code Snippets/createindex.snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> | ||
<_locDefinition xmlns="urn:locstudio"> | ||
<_locDefault _loc="locNone" /> | ||
<_locTag _loc="locData">Title</_locTag> | ||
<_locTag _loc="locData">Description</_locTag> | ||
<_locTag _loc="locData">Author</_locTag> | ||
<_locTag _loc="locData">ToolTip</_locTag> | ||
</_locDefinition> | ||
<CodeSnippet Format="1.0.0"> | ||
<Header> | ||
<Title>My Create Index</Title> | ||
<Shortcut>mycreateindex</Shortcut> | ||
<Description>Creates an index.</Description> | ||
<Author>Rudi Breedenraedt</Author> | ||
<SnippetTypes> | ||
<SnippetType>Expansion</SnippetType> | ||
</SnippetTypes> | ||
</Header> | ||
<Snippet> | ||
<Declarations> | ||
<Literal> | ||
<ID>SchemaName</ID> | ||
<ToolTip>Name of the schema</ToolTip> | ||
<Default>dbo</Default> | ||
</Literal> | ||
<Literal> | ||
<ID>Tablename</ID> | ||
<ToolTip>Name of the table</ToolTip> | ||
<Default>Sample_Table</Default> | ||
</Literal> | ||
<Literal> | ||
<ID>Columnname</ID> | ||
<ToolTip>Name of the column</ToolTip> | ||
<Default>Sample_Column</Default> | ||
</Literal> | ||
<Literal> | ||
<ID>Uniqueness</ID> | ||
<ToolTip>UNIQUE or empty</ToolTip> | ||
<Default>UNIQUE</Default> | ||
</Literal> | ||
</Declarations> | ||
<Code Language="SQL"> | ||
<![CDATA[-- ------------------------------------------------------------ | ||
-- CREATE INDEX [$SchemaName$].[IX_$Tablename$_$Columnname$] | ||
-- ------------------------------------------------------------ | ||
CREATE $Uniqueness$ NONCLUSTERED INDEX [IX_$Tablename$_$Columnname$] ON [$SchemaName$].[$Tablename$] ([$Columnname$] ASC) | ||
GO | ||
|
||
$end$]]> | ||
</Code> | ||
</Snippet> | ||
</CodeSnippet> | ||
</CodeSnippets> | ||
|
122 changes: 122 additions & 0 deletions
122
...er Management Studio/Code Snippets/SQL/My Code Snippets/createmanytomanyreference.snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> | ||
<_locDefinition xmlns="urn:locstudio"> | ||
<_locDefault _loc="locNone" /> | ||
<_locTag _loc="locData">Title</_locTag> | ||
<_locTag _loc="locData">Description</_locTag> | ||
<_locTag _loc="locData">Author</_locTag> | ||
<_locTag _loc="locData">ToolTip</_locTag> | ||
</_locDefinition> | ||
<CodeSnippet Format="1.0.0"> | ||
<Header> | ||
<Title>My Create Many to Many Reference Table</Title> | ||
<Shortcut>mycreatemanyref</Shortcut> | ||
<Description>Creates a many to many reference table.</Description> | ||
<Author>Rudi Breedenraedt</Author> | ||
<SnippetTypes> | ||
<SnippetType>Expansion</SnippetType> | ||
</SnippetTypes> | ||
</Header> | ||
<Snippet> | ||
<Declarations> | ||
<Literal> | ||
<ID>SchemaName</ID> | ||
<ToolTip>Name of the schema</ToolTip> | ||
<Default>dbo</Default> | ||
</Literal> | ||
<Literal> | ||
<ID>Tablename</ID> | ||
<ToolTip>Name of the table</ToolTip> | ||
<Default>Invoice</Default> | ||
</Literal> | ||
<Literal> | ||
<ID>PrimaryKey</ID> | ||
<ToolTip>Name of the refered key column</ToolTip> | ||
<Default>Id</Default> | ||
</Literal> | ||
<Literal> | ||
<ID>Rolename</ID> | ||
<ToolTip>Name of the role</ToolTip> | ||
<Default>Customer</Default> | ||
</Literal> | ||
<Literal> | ||
<ID>ForeignKeyPostfix</ID> | ||
<ToolTip>Postfix of the foreign key column</ToolTip> | ||
<Default>Id</Default> | ||
</Literal> | ||
<Literal> | ||
<ID>RefSchemaName</ID> | ||
<ToolTip>Name of the referenced schema</ToolTip> | ||
<Default>dbo</Default> | ||
</Literal> | ||
<Literal> | ||
<ID>RefTablename</ID> | ||
<ToolTip>Name of the referenced table</ToolTip> | ||
<Default>Customer</Default> | ||
</Literal> | ||
<Literal> | ||
<ID>RefPrimaryKey</ID> | ||
<ToolTip>Name of the referred key column of the referenced table</ToolTip> | ||
<Default>Id</Default> | ||
</Literal> | ||
<Literal> | ||
<ID>OnUpdate1</ID> | ||
<ToolTip>ON UPDATE action (NO ACTION | CASCADE | SET NULL | SET DEFAULT)</ToolTip> | ||
<Default>NO ACTION</Default> | ||
</Literal> | ||
<Literal> | ||
<ID>OnDelete1</ID> | ||
<ToolTip>ON DELETE action (NO ACTION | CASCADE | SET NULL | SET DEFAULT)</ToolTip> | ||
<Default>NO ACTION</Default> | ||
</Literal> | ||
<Literal> | ||
<ID>OnUpdate2</ID> | ||
<ToolTip>ON UPDATE action (NO ACTION | CASCADE | SET NULL | SET DEFAULT)</ToolTip> | ||
<Default>NO ACTION</Default> | ||
</Literal> | ||
<Literal> | ||
<ID>OnDelete2</ID> | ||
<ToolTip>ON DELETE action (NO ACTION | CASCADE | SET NULL | SET DEFAULT)</ToolTip> | ||
<Default>NO ACTION</Default> | ||
</Literal> | ||
</Declarations> | ||
<Code Language="SQL"> | ||
<![CDATA[-- ------------------------------------------------------------ | ||
-- CREATE REFERENCE [$SchemaName$].[$Tablename$] ---<$Rolename$>---> [$RefSchemaName$].[$RefTablename$] | ||
-- ------------------------------------------------------------ | ||
|
||
-- Create many-to-many reference table: | ||
CREATE TABLE [$SchemaName$].[$Tablename$_$Rolename$] | ||
( | ||
[$Tablename$$ForeignKeyPostfix$] int NOT NULL, | ||
[$RefTablename$$ForeignKeyPostfix$] int NOT NULL, | ||
CONSTRAINT [PK_$Tablename$_$Rolename$] PRIMARY KEY CLUSTERED ([$Tablename$$ForeignKeyPostfix$] ASC, [$RefTablename$$ForeignKeyPostfix$] ASC) | ||
) ON [PRIMARY] | ||
GO | ||
|
||
-- Create the foreign key constraint and check it for existing data: | ||
ALTER TABLE [$SchemaName$].[$Tablename$_$Rolename$] WITH CHECK ADD CONSTRAINT [FK_$Tablename$_$Rolename$_$Tablename$] FOREIGN KEY([$Tablename$$ForeignKeyPostfix$]) | ||
REFERENCES [$SchemaName$].[$Tablename$] ([$PrimaryKey$]) | ||
ON UPDATE $OnUpdate1$ | ||
ON DELETE $OnDelete1$ | ||
GO | ||
|
||
ALTER TABLE [$SchemaName$].[$Tablename$_$Rolename$] WITH CHECK ADD CONSTRAINT [FK_$Tablename$_$Rolename$_$Rolename$] FOREIGN KEY([$RefTablename$$ForeignKeyPostfix$]) | ||
REFERENCES [$RefSchemaName$].[$RefTablename$] ([$RefPrimaryKey$]) | ||
ON UPDATE $OnUpdate2$ | ||
ON DELETE $OnDelete2$ | ||
GO | ||
|
||
-- Enable the constraint for future data: | ||
ALTER TABLE [$SchemaName$].[$Tablename$_$Rolename$] CHECK CONSTRAINT [FK_$Tablename$_$Rolename$_$Tablename$] | ||
GO | ||
|
||
ALTER TABLE [$SchemaName$].[$Tablename$_$Rolename$] CHECK CONSTRAINT [FK_$Tablename$_$Rolename$_$Rolename$] | ||
GO | ||
|
||
$end$]]> | ||
</Code> | ||
</Snippet> | ||
</CodeSnippet> | ||
</CodeSnippets> | ||
|
93 changes: 93 additions & 0 deletions
93
...t SQL Server Management Studio/Code Snippets/SQL/My Code Snippets/createreference.snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> | ||
<_locDefinition xmlns="urn:locstudio"> | ||
<_locDefault _loc="locNone" /> | ||
<_locTag _loc="locData">Title</_locTag> | ||
<_locTag _loc="locData">Description</_locTag> | ||
<_locTag _loc="locData">Author</_locTag> | ||
<_locTag _loc="locData">ToolTip</_locTag> | ||
</_locDefinition> | ||
<CodeSnippet Format="1.0.0"> | ||
<Header> | ||
<Title>My Create Foreign Key Reference</Title> | ||
<Shortcut>mycreateref</Shortcut> | ||
<Description>Creates a foreign key reference.</Description> | ||
<Author>Rudi Breedenraedt</Author> | ||
<SnippetTypes> | ||
<SnippetType>Expansion</SnippetType> | ||
</SnippetTypes> | ||
</Header> | ||
<Snippet> | ||
<Declarations> | ||
<Literal> | ||
<ID>SchemaName</ID> | ||
<ToolTip>Name of the schema</ToolTip> | ||
<Default>dbo</Default> | ||
</Literal> | ||
<Literal> | ||
<ID>Tablename</ID> | ||
<ToolTip>Name of the table</ToolTip> | ||
<Default>Invoice</Default> | ||
</Literal> | ||
<Literal> | ||
<ID>Rolename</ID> | ||
<ToolTip>Name of the role</ToolTip> | ||
<Default>Customer</Default> | ||
</Literal> | ||
<Literal> | ||
<ID>ForeignKeyPostfix</ID> | ||
<ToolTip>Postfix of the foreign key column</ToolTip> | ||
<Default>Id</Default> | ||
</Literal> | ||
<Literal> | ||
<ID>RefSchemaName</ID> | ||
<ToolTip>Name of the referenced schema</ToolTip> | ||
<Default>dbo</Default> | ||
</Literal> | ||
<Literal> | ||
<ID>RefTablename</ID> | ||
<ToolTip>Name of the referenced table</ToolTip> | ||
<Default>Customer</Default> | ||
</Literal> | ||
<Literal> | ||
<ID>PrimaryKey</ID> | ||
<ToolTip>Name of the refered key column</ToolTip> | ||
<Default>Id</Default> | ||
</Literal> | ||
<Literal> | ||
<ID>OnUpdate</ID> | ||
<ToolTip>ON UPDATE action (NO ACTION | CASCADE | SET NULL | SET DEFAULT)</ToolTip> | ||
<Default>NO ACTION</Default> | ||
</Literal> | ||
<Literal> | ||
<ID>OnDelete</ID> | ||
<ToolTip>ON DELETE action (NO ACTION | CASCADE | SET NULL | SET DEFAULT)</ToolTip> | ||
<Default>NO ACTION</Default> | ||
</Literal> | ||
</Declarations> | ||
<Code Language="SQL"> | ||
<![CDATA[-- ------------------------------------------------------------ | ||
-- CREATE REFERENCE [$SchemaName$].[$Tablename$] ---<$Rolename$>---> [$RefSchemaName$].[$RefTablename$] | ||
-- ------------------------------------------------------------ | ||
|
||
-- Create an index on the foreign key column: | ||
CREATE NONCLUSTERED INDEX [IX_$Tablename$_$Rolename$$ForeignKeyPostfix$] ON [$SchemaName$].[$Tablename$] ([$Rolename$$ForeignKeyPostfix$] ASC) | ||
GO | ||
|
||
-- Create the foreign key constraint and check it for existing data: | ||
ALTER TABLE [$SchemaName$].[$Tablename$] WITH CHECK ADD CONSTRAINT [FK_$Tablename$_$Rolename$] FOREIGN KEY([$Rolename$$ForeignKeyPostfix$]) | ||
REFERENCES [$RefSchemaName$].[$RefTablename$] ([$PrimaryKey$]) | ||
ON UPDATE $OnUpdate$ | ||
ON DELETE $OnDelete$ | ||
GO | ||
|
||
-- Enable the constraint for future data: | ||
ALTER TABLE [$SchemaName$].[$Tablename$] CHECK CONSTRAINT [FK_$Tablename$_$Rolename$] | ||
GO | ||
|
||
$end$]]> | ||
</Code> | ||
</Snippet> | ||
</CodeSnippet> | ||
</CodeSnippets> | ||
|
43 changes: 43 additions & 0 deletions
43
...soft SQL Server Management Studio/Code Snippets/SQL/My Code Snippets/createschema.snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> | ||
<_locDefinition xmlns="urn:locstudio"> | ||
<_locDefault _loc="locNone" /> | ||
<_locTag _loc="locData">Title</_locTag> | ||
<_locTag _loc="locData">Description</_locTag> | ||
<_locTag _loc="locData">Author</_locTag> | ||
<_locTag _loc="locData">ToolTip</_locTag> | ||
</_locDefinition> | ||
<CodeSnippet Format="1.0.0"> | ||
<Header> | ||
<Title>My Create Schema</Title> | ||
<Shortcut>mycreateschema</Shortcut> | ||
<Description>Creates a schema.</Description> | ||
<Author>Rudi Breedenraedt</Author> | ||
<SnippetTypes> | ||
<SnippetType>Expansion</SnippetType> | ||
</SnippetTypes> | ||
</Header> | ||
<Snippet> | ||
<Declarations> | ||
<Literal> | ||
<ID>SchemaName</ID> | ||
<ToolTip>Name of the schema</ToolTip> | ||
<Default>dbo</Default> | ||
</Literal> | ||
</Declarations> | ||
<Code Language="SQL"> | ||
<![CDATA[-- ------------------------------------------------------------ | ||
-- CREATE SCHEMA [$SchemaName$] | ||
-- ------------------------------------------------------------ | ||
IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = '$SchemaName$') | ||
BEGIN | ||
EXECUTE ('CREATE SCHEMA [$SchemaName$] AUTHORIZATION [dbo]') | ||
END | ||
GO | ||
|
||
$end$]]> | ||
</Code> | ||
</Snippet> | ||
</CodeSnippet> | ||
</CodeSnippets> | ||
|
54 changes: 54 additions & 0 deletions
54
...Server Management Studio/Code Snippets/SQL/My Code Snippets/createstoredprocedure.snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> | ||
<_locDefinition xmlns="urn:locstudio"> | ||
<_locDefault _loc="locNone" /> | ||
<_locTag _loc="locData">Title</_locTag> | ||
<_locTag _loc="locData">Description</_locTag> | ||
<_locTag _loc="locData">Author</_locTag> | ||
<_locTag _loc="locData">ToolTip</_locTag> | ||
</_locDefinition> | ||
<CodeSnippet Format="1.0.0"> | ||
<Header> | ||
<Title>My Create Stored Procedure</Title> | ||
<Shortcut>mycreatestoredprocedure</Shortcut> | ||
<Description>Creates a stored procedure.</Description> | ||
<Author>Rudi Breedenraedt</Author> | ||
<SnippetTypes> | ||
<SnippetType>Expansion</SnippetType> | ||
</SnippetTypes> | ||
</Header> | ||
<Snippet> | ||
<Declarations> | ||
<Literal> | ||
<ID>SchemaName</ID> | ||
<ToolTip>Name of the schema</ToolTip> | ||
<Default>dbo</Default> | ||
</Literal> | ||
<Literal> | ||
<ID>Procname</ID> | ||
<ToolTip>Name of the stored procedure</ToolTip> | ||
<Default>usp_NewProcedure</Default> | ||
</Literal> | ||
</Declarations> | ||
<Code Language="SQL"> | ||
<![CDATA[-- ====================================================================================================== | ||
-- StoredProcedure: [$SchemaName$].[$Procname$] | ||
|
||
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[$SchemaName$].[$Procname$]') AND type in (N'P', N'PC')) | ||
EXECUTE ('CREATE PROCEDURE [$SchemaName$].[$Procname$] AS SELECT 0') | ||
GO | ||
|
||
|
||
ALTER PROCEDURE [$SchemaName$].[$Procname$] | ||
AS | ||
BEGIN | ||
$end$ | ||
END | ||
GO | ||
|
||
]]> | ||
</Code> | ||
</Snippet> | ||
</CodeSnippet> | ||
</CodeSnippets> | ||
|
Oops, something went wrong.