mirror of
https://github.com/Microsoft/sql-server-samples.git
synced 2025-12-08 14:58:54 +00:00
Reconciling SQL Templatates that ship with SSMS with the ones on GitHub.
This commit is contained in:
+1
-1
@@ -7,7 +7,7 @@ GO
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM sys.external_data_sources
|
||||
WHERE name = N'<data_source_name, sysname, your_data_source_name>'
|
||||
WHERE name = N'<data_source_name, sysname, sample_data_source>'
|
||||
)
|
||||
DROP EXTERNAL DATA SOURCE <data_source_name, sysname, sample_data_source>
|
||||
GO
|
||||
|
||||
+2
-2
@@ -6,8 +6,8 @@ GO
|
||||
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM sys.external_data_sources
|
||||
WHERE name = N'<data_source_name, sysname, your_data_source_name>'
|
||||
FROM sys.external_data_sources
|
||||
WHERE name = N'<data_source_name, sysname, sample_data_source>'
|
||||
)
|
||||
DROP EXTERNAL DATA SOURCE <data_source_name, sysname, sample_data_source>
|
||||
GO
|
||||
+12
-9
@@ -1,5 +1,5 @@
|
||||
-- ===================================================================================================================================
|
||||
-- Create database template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
-- Create database template for Azure SQL Database and Azure Synapse Analytics Database
|
||||
--
|
||||
-- This script will only run in the context of the master database. To manage this database in
|
||||
-- SQL Server Management Studio, either connect to the created database, or connect to master.
|
||||
@@ -9,27 +9,30 @@
|
||||
-- continuity, data protection and security, and near-zero administration — all backed by the power
|
||||
-- and reach of Microsoft Azure.
|
||||
--
|
||||
-- SQL Database is available in the following service tiers: Basic, Standard, Premium , DataWarehouse, Web (Retired)
|
||||
-- SQL Database is available in the following service tiers: GeneralPurpose, Basic, Standard, Premium , DataWarehouse, Web (Retired)
|
||||
-- and Business (Retired).
|
||||
-- General Purpose service tier is a default service tier in Azure SQL Database that is designed for most of the generic workloads.
|
||||
-- If you need a fully managed database engine with 99.99% SLA with storage latency between 5 and 10 ms that match Azure SQL
|
||||
-- IaaS in most of the cases, General Purpose tier is the option for you.
|
||||
-- Standard is the go-to option for getting started with cloud-designed business applications and
|
||||
-- offers mid-level performance and business continuity features. Performance objectives for Standard
|
||||
-- deliver predictable per minute transaction rates.
|
||||
--
|
||||
-- See http://go.microsoft.com/fwlink/p/?LinkId=306622 for more information about Azure SQL Database.
|
||||
-- See https://go.microsoft.com/fwlink/p/?LinkId=306622 for more information about Azure SQL Database.
|
||||
--
|
||||
-- See http://go.microsoft.com/fwlink/?LinkId=787140 for more information about Azure SQL Data Warehouse.
|
||||
-- See https://go.microsoft.com/fwlink/?LinkId=787140 for more information about Azure Synapse Analytics.
|
||||
--
|
||||
-- See http://go.microsoft.com/fwlink/p/?LinkId=402063 for more information about CREATE DATABASE for Azure SQL Database.
|
||||
-- See https://go.microsoft.com/fwlink/p/?LinkId=402063 for more information about CREATE DATABASE for Azure SQL Database.
|
||||
--
|
||||
-- See http://go.microsoft.com/fwlink/?LinkId=787139 for more information about CREATE DATABASE for Azure SQL Data Warehouse Database.
|
||||
-- See https://go.microsoft.com/fwlink/?LinkId=787139 for more information about CREATE DATABASE for Azure Synapse Analytics Database.
|
||||
-- ===================================================================================================================================
|
||||
|
||||
|
||||
CREATE DATABASE <Database_Name, sysname, Database_Name> COLLATE <collation_Name, sysname, SQL_Latin1_General_CP1_CI_AS>
|
||||
(
|
||||
EDITION = '<EDITION, , Standard>',
|
||||
SERVICE_OBJECTIVE='<SERVICE_OBJECTIVE,,S0>',
|
||||
MAXSIZE = <MAX_SIZE,,250 GB>
|
||||
EDITION = '<EDITION, , GeneralPurpose>',
|
||||
SERVICE_OBJECTIVE='<SERVICE_OBJECTIVE,,GP_Gen5_2>',
|
||||
MAXSIZE = <MAX_SIZE,,32 GB>
|
||||
)
|
||||
|
||||
GO
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- ===================================================================================
|
||||
-- Drop database template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
-- ===================================================================================
|
||||
-- ===================================================================================================================================
|
||||
-- Drop database template for Azure SQL Database, Azure Synapse Analytics Database, and Azure Synapse SQL Analytics on-demand Database
|
||||
-- ===================================================================================================================================
|
||||
DROP DATABASE <Database_Name, sysname, Database_Name>
|
||||
GO
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
-- =========================================================================
|
||||
-- Alter external data source template for Azure SQL Data Warehouse Database
|
||||
-- =========================================================================
|
||||
-- ========================================================================
|
||||
-- Alter external data source template for Azure Synapse Analytics Database
|
||||
-- ========================================================================
|
||||
|
||||
ALTER EXTERNAL DATA SOURCE <data_source_name, sysname, sample_data_source> SET
|
||||
LOCATION = N'<location, sysname, sample_location>',
|
||||
|
||||
+9
-9
@@ -1,20 +1,20 @@
|
||||
-- ==========================================================================
|
||||
-- Create external data source template for Azure SQL Data Warehouse Database
|
||||
-- ==========================================================================
|
||||
-- =========================================================================
|
||||
-- Create external data source template for Azure Synapse Analytics Database
|
||||
-- =========================================================================
|
||||
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM sys.external_data_sources
|
||||
WHERE name = N'<data_source_name, sysname, your_data_source_name>'
|
||||
FROM sys.external_data_sources
|
||||
WHERE name = N'<data_source_name, sysname, sample_data_source>'
|
||||
)
|
||||
DROP EXTERNAL DATA SOURCE <data_source_name, sysname, sample_data_source>
|
||||
GO
|
||||
|
||||
CREATE EXTERNAL DATA SOURCE <data_source_name, sysname, sample_data_source> WITH
|
||||
(
|
||||
TYPE = <data_source_type, sysname, sample_type>,
|
||||
LOCATION = N'<location, sysname, sample_location>',
|
||||
RESOURCE_MANAGER_LOCATION = N'<resource_manager_location, sysname, sample_resource_manager_location>',
|
||||
CREDENTIAL = <credential_name, sysname, sample_credential>
|
||||
TYPE = <data_source_type, sysname, sample_type>,
|
||||
LOCATION = N'<location, sysname, sample_location>',
|
||||
RESOURCE_MANAGER_LOCATION = N'<resource_manager_location, sysname, sample_resource_manager_location>',
|
||||
CREDENTIAL = <credential_name, sysname, sample_credential>
|
||||
)
|
||||
GO
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM sys.external_data_sources
|
||||
WHERE name = N'<data_source_name, sysname, your_data_source_name>'
|
||||
WHERE name = N'<data_source_name, sysname, sample_data_source>'
|
||||
)
|
||||
DROP EXTERNAL DATA SOURCE <data_source_name, sysname, sample_data_source>
|
||||
GO
|
||||
|
||||
+5
-5
@@ -1,11 +1,11 @@
|
||||
-- ===============================================================================================
|
||||
-- Drop external data source template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
-- ===============================================================================================
|
||||
-- ======================================================================================================================================
|
||||
-- Drop external data source template for Azure SQL Database, Azure Synapse Analytics Database, and Azure Synapse SQL Analytics on-demand
|
||||
-- ======================================================================================================================================
|
||||
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM sys.external_data_sources
|
||||
WHERE name = N'<data_source_name, sysname, your_data_source_name>'
|
||||
FROM sys.external_data_sources
|
||||
WHERE name = N'<data_source_name, sysname, sample_data_source>'
|
||||
)
|
||||
DROP EXTERNAL DATA SOURCE <data_source_name, sysname, sample_data_source>
|
||||
GO
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
-- ==========================================================================
|
||||
-- Create external file format template for Azure SQL Data Warehouse Database
|
||||
-- ==========================================================================
|
||||
-- =========================================================================
|
||||
-- Create external file format template for Azure Synapse Analytics Database
|
||||
-- =========================================================================
|
||||
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
-- ========================================================================
|
||||
-- Drop external file format template for Azure SQL Data Warehouse Database
|
||||
-- ========================================================================
|
||||
-- ==================================================================================================================
|
||||
-- Drop external file format template for Azure Synapse Analytics Database, and Azure Synapse SQL Analytics on-demand
|
||||
-- ==================================================================================================================
|
||||
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
-- =====================================================================
|
||||
-- Create Scalar Function Template for Azure SQL Data Warehouse Database
|
||||
-- =====================================================================
|
||||
-- ====================================================================
|
||||
-- Create Scalar Function Template for Azure Synapse Analytics Database
|
||||
-- ====================================================================
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--===================================================================================
|
||||
-- Drop function template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
--====================================================================================
|
||||
--==================================================================================
|
||||
-- Drop function template for Azure SQL Database and Azure Synapse Analytics Database
|
||||
--===================================================================================
|
||||
IF OBJECT_ID (N'<schema_name, sysname, dbo>.<function_name, sysname, EmployeeByID>') IS NOT NULL
|
||||
DROP FUNCTION <schema_name, sysname, dbo>.<function_name, sysname, EmployeeByID>
|
||||
GO
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- ==================================================================================
|
||||
-- Create index template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
-- ==================================================================================
|
||||
-- =================================================================================
|
||||
-- Create index template for Azure SQL Database and Azure Synapse Analytics Database
|
||||
-- =================================================================================
|
||||
|
||||
CREATE INDEX <index_name, sysname, ind_test>
|
||||
ON <schema_name, sysname, Person>.<table_name, sysname, Address>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--========================================================================
|
||||
-- Drop index template for Azure SQL Database and Azure SQL Data Warehouse
|
||||
--========================================================================
|
||||
--=======================================================================
|
||||
-- Drop index template for Azure SQL Database and Azure Synapse Analytics
|
||||
--=======================================================================
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM sys.indexes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- ======================================================================================
|
||||
-- Create SQL Login template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
-- ======================================================================================
|
||||
-- =============================================================================================================================
|
||||
-- Create SQL Login template for Azure SQL Database, Azure Synapse Analytics Database, and Azure Synapse SQL Analytics on-demand
|
||||
-- =============================================================================================================================
|
||||
|
||||
CREATE LOGIN <SQL_login_name, sysname, login_name>
|
||||
WITH PASSWORD = '<password, sysname, Change_Password>'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- ====================================================================================
|
||||
-- Drop SQL Login template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
-- ====================================================================================
|
||||
-- ===========================================================================================================================
|
||||
-- Drop SQL Login template for Azure SQL Database, Azure Synapse Analytics Database, and Azure Synapse SQL Analytics on-demand
|
||||
-- ===========================================================================================================================
|
||||
|
||||
DROP LOGIN <login_name, sysname, login_name>
|
||||
Go
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- ==========================================================================================
|
||||
-- Create Database Role template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
-- ==========================================================================================
|
||||
-- =========================================================================================
|
||||
-- Create Database Role template for Azure SQL Database and Azure Synapse Analytics Database
|
||||
-- =========================================================================================
|
||||
-- Create the database role
|
||||
CREATE ROLE <role_name, sysname, Production_Owner> AUTHORIZATION [dbo]
|
||||
GO
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- ========================================================================================
|
||||
-- Drop Database Role template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
-- ========================================================================================
|
||||
-- ===============================================================================================================================
|
||||
-- Drop Database Role template for Azure SQL Database, Azure Synapse Analytics Database, and Azure Synapse SQL Analytics on-demand
|
||||
-- ===============================================================================================================================
|
||||
|
||||
-- Drop the role
|
||||
DROP ROLE <role_name, sysname, Production_Owner>;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- ===================================================================================
|
||||
-- Create Schema Template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
-- ===================================================================================
|
||||
-- ==========================================================================================================================
|
||||
-- Create Schema Template for Azure SQL Database, Azure Synapse Analytics Database, and Azure Synapse SQL Analytics on-demand
|
||||
-- ==========================================================================================================================
|
||||
|
||||
CREATE SCHEMA <sample_schema, sysname, sample_schema>
|
||||
AUTHORIZATION <owner_name, sysname, owner_name>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--==================================================================================
|
||||
-- Drop Schema template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
--==================================================================================
|
||||
--=========================================================================================================================
|
||||
-- Drop Schema template for Azure SQL Database, Azure Synapse Analytics Database, and Azure Synapse SQL Analytics on-demand
|
||||
--=========================================================================================================================
|
||||
IF EXISTS(
|
||||
SELECT *
|
||||
FROM sys.schemas
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
-- ===============================================================================================
|
||||
-- Create Sampled Statistics Template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
-- ===============================================================================================
|
||||
-- ======================================================================================================================================
|
||||
-- Create Sampled Statistics Template for Azure SQL Database, Azure Synapse Analytics Database, and Azure Synapse SQL Analytics on-demand
|
||||
-- ======================================================================================================================================
|
||||
CREATE STATISTICS <statistics_name, sysname, statistics_name>
|
||||
ON <schema_name, sysname, schema_name>.<table_name, sysname, table_name>
|
||||
(
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
--======================================================================================
|
||||
-- Drop Statistics template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
--======================================================================================
|
||||
--=============================================================================================================================
|
||||
-- Drop Statistics template for Azure SQL Database, Azure Synapse Analytics Database, and Azure Synapse SQL Analytics on-demand
|
||||
--=============================================================================================================================
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM sys.stats as st
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
-- ======================================================================
|
||||
-- Create Stored Procedure Template for Azure SQL Data Warehouse Database
|
||||
-- ======================================================================
|
||||
-- =====================================================================
|
||||
-- Create Stored Procedure Template for Azure Synapse Analytics Database
|
||||
-- =====================================================================
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
-- ===========================================================================================
|
||||
-- Drop Stored Procedure Template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
-- ===========================================================================================
|
||||
-- ==========================================================================================
|
||||
-- Drop Stored Procedure Template for Azure SQL Database and Azure Synapse Analytics Database
|
||||
-- ==========================================================================================
|
||||
|
||||
-- Drop stored procedure if it already exists
|
||||
IF EXISTS (
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
-- ====================================================================
|
||||
-- Create External Table Template for Azure SQL Data Warehouse Database
|
||||
-- ====================================================================
|
||||
-- ===================================================================
|
||||
-- Create External Table Template for Azure Synapse Analytics Database
|
||||
-- ===================================================================
|
||||
|
||||
IF OBJECT_ID('<schema_name, sysname, dbo>.<table_name, sysname, sample_external_table>', 'U') IS NOT NULL
|
||||
DROP EXTERNAL TABLE <schema_name, sysname, dbo>.<table_name, sysname, sample_external_table>
|
||||
|
||||
+13
-5
@@ -1,24 +1,32 @@
|
||||
-- =========================================
|
||||
-- Create Graph Edge Template
|
||||
-- Create Graph Edge Table Template
|
||||
-- =========================================
|
||||
USE <database, sysname, AdventureWorks>
|
||||
GO
|
||||
|
||||
IF OBJECT_ID('<schema_name, sysname, dbo>.<table_name, sysname, sample_edgetable>', 'U') IS NOT NULL
|
||||
DROP TABLE <schema_name, sysname, dbo>.<table_name, sysname, sample_edgetable>
|
||||
DROP TABLE IF EXISTS <schema_name, sysname, dbo>.<table_name, sysname, sample_edgetable>
|
||||
GO
|
||||
|
||||
CREATE TABLE <schema_name, sysname, dbo>.<table_name, sysname, sample_edgetable>
|
||||
(
|
||||
-- Columns are optional for Edge Tables.
|
||||
-- Columns are optional for Graph Edge Tables.
|
||||
--
|
||||
<column1_name, sysname, c1> <column1_datatype, , int> <column1_nullability, , NOT NULL>,
|
||||
<column2_name, sysname, c2> <column2_datatype, , char(10)> <column2_nullability, , NULL>,
|
||||
<column3_name, sysname, c3> <column3_datatype, , datetime> <column3_nullability, , NULL>,
|
||||
|
||||
-- System generated edge constraint.
|
||||
--
|
||||
CONNECTION (<node_table_name TO <node_table_name>),
|
||||
|
||||
CONSTRAINT EC_<constraint_name> CONNECTION (<node_table_name TO <node_table_name>, <node_table_name> TO <node_table_name>),
|
||||
-- Unique index on $edge_id is required.
|
||||
-- If no user-defined index is specified, a default index is created instead.
|
||||
-- If no user-defined index is specified, a default index is created.
|
||||
--
|
||||
INDEX ix_graphid UNIQUE ($edge_id),
|
||||
|
||||
-- indexes on $from_id and $to_id are optional, but support faster lookups.
|
||||
--
|
||||
INDEX ix_fromid ($from_id, $to_id),
|
||||
INDEX ix_toid ($to_id, $from_id)
|
||||
)
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
-- =======================================================================
|
||||
-- Create Partitioned Table Template for Azure SQL Data Warehouse Database
|
||||
-- =======================================================================
|
||||
-- ======================================================================
|
||||
-- Create Partitioned Table Template for Azure Synapse Analytics Database
|
||||
-- ======================================================================
|
||||
|
||||
IF OBJECT_ID('<schema_name, sysname, dbo>.<table_name, sysname, sample_table>', 'U') IS NOT NULL
|
||||
DROP TABLE <schema_name, sysname, dbo>.<table_name, sysname, sample_table>
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
-- ===========================================================
|
||||
-- Create Table Template for Azure SQL Data Warehouse Database
|
||||
-- ===========================================================
|
||||
-- ==========================================================
|
||||
-- Create Table Template for Azure Synapse Analytics Database
|
||||
-- ==========================================================
|
||||
|
||||
IF OBJECT_ID('<schema_name, sysname, dbo>.<table_name, sysname, sample_table>', 'U') IS NOT NULL
|
||||
DROP TABLE <schema_name, sysname, dbo>.<table_name, sysname, sample_table>
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
|
||||
BEGIN
|
||||
--If table is system-versioned, SYSTEM_VERSIONING must be set to OFF first
|
||||
IF ((SELECT temporal_type FROM SYS.TABLES WHERE object_id = OBJECT_ID('<schema_name, sysname, dbo>.<temporal_table_name, sysname, sample_table>', 'U')) = 2)
|
||||
IF ((SELECT temporal_type FROM sys.tables WHERE object_id = OBJECT_ID('<schema_name, sysname, dbo>.<temporal_table_name, sysname, sample_table>', 'U')) = 2)
|
||||
BEGIN
|
||||
ALTER TABLE [<schema_name, sysname, dbo>].[<temporal_table_name, sysname, sample_table>] SET (SYSTEM_VERSIONING = OFF)
|
||||
END
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
--==========================================================================================
|
||||
-- Drop External Table template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
--==========================================================================================
|
||||
--=================================================================================================================================
|
||||
-- Drop External Table template for Azure SQL Database, Azure Synapse Analytics Database, and Azure Synapse SQL Analytics on-demand
|
||||
--=================================================================================================================================
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM sys.tables
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--=================================================================================
|
||||
-- Drop Table template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
--=================================================================================
|
||||
--================================================================================
|
||||
-- Drop Table template for Azure SQL Database and Azure Synapse Analytics Database
|
||||
--================================================================================
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM sys.tables
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- ========================================================================================
|
||||
-- Create User as DBO template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
-- ========================================================================================
|
||||
-- =======================================================================================
|
||||
-- Create User as DBO template for Azure SQL Database and Azure Synapse Analytics Database
|
||||
-- =======================================================================================
|
||||
-- For login <login_name, sysname, login_name>, create a user in the database
|
||||
CREATE USER <user_name, sysname, user_name>
|
||||
FOR LOGIN <login_name, sysname, login_name>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- ========================================================================================
|
||||
-- Create User as DBO template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
-- ========================================================================================
|
||||
-- ===============================================================================================================================
|
||||
-- Create User as DBO template for Azure SQL Database, Azure Synapse Analytics Database, and Azure Synapse SQL Analytics on-demand
|
||||
-- ===============================================================================================================================
|
||||
DROP USER <user_name, sysname, user_name>
|
||||
GO
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- =================================================================================
|
||||
-- Create View template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
-- =================================================================================
|
||||
-- ================================================================================
|
||||
-- Create View template for Azure SQL Database and Azure Synapse Analytics Database
|
||||
-- ================================================================================
|
||||
|
||||
IF object_id(N'<schema_name, sysname, dbo>.<view_name, sysname, Top10Sales>', 'V') IS NOT NULL
|
||||
DROP VIEW <schema_name, sysname, dbo>.<view_name, sysname, Top10Sales>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--================================================================================
|
||||
-- Drop View template for Azure SQL Database and Azure SQL Data Warehouse Database
|
||||
--================================================================================
|
||||
--=======================================================================================================================
|
||||
-- Drop View template for Azure SQL Database, Azure Synapse Analytics Database, and Azure Synapse SQL Analytics on-demand
|
||||
--=======================================================================================================================
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM sys.views
|
||||
|
||||
@@ -1,26 +1,32 @@
|
||||
-- =========================================
|
||||
-- Create Graph Edge Template
|
||||
-- Create Graph Edge Table Template
|
||||
-- =========================================
|
||||
USE <database, sysname, AdventureWorks>
|
||||
GO
|
||||
|
||||
IF OBJECT_ID('<schema_name, sysname, dbo>.<table_name, sysname, sample_edgetable>', 'U') IS NOT NULL
|
||||
DROP TABLE <schema_name, sysname, dbo>.<table_name, sysname, sample_edgetable>
|
||||
DROP TABLE IF EXISTS <schema_name, sysname, dbo>.<table_name, sysname, sample_edgetable>
|
||||
GO
|
||||
|
||||
CREATE TABLE <schema_name, sysname, dbo>.<table_name, sysname, sample_edgetable>
|
||||
(
|
||||
-- Columns are optional for Edge Tables.
|
||||
-- Columns are optional for Graph Edge Tables.
|
||||
--
|
||||
<column1_name, sysname, c1> <column1_datatype, , int> <column1_nullability, , NOT NULL>,
|
||||
<column2_name, sysname, c2> <column2_datatype, , char(10)> <column2_nullability, , NULL>,
|
||||
<column3_name, sysname, c3> <column3_datatype, , datetime> <column3_nullability, , NULL>,
|
||||
|
||||
-- System generated edge constraint.
|
||||
--
|
||||
CONNECTION (<node_table_name TO <node_table_name>),
|
||||
|
||||
CONSTRAINT EC_<constraint_name> CONNECTION (<node_table_name TO <node_table_name>, <node_table_name> TO <node_table_name>),
|
||||
-- Unique index on $edge_id is required.
|
||||
-- If no user-defined index is specified, a default index is created.
|
||||
--
|
||||
INDEX ix_graphid UNIQUE ($edge_id),
|
||||
|
||||
-- indexes on $from_id and $to_id are optional, but support faster lookups.
|
||||
--
|
||||
INDEX ix_fromid ($from_id, $to_id),
|
||||
INDEX ix_toid ($to_id, $from_id)
|
||||
)
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ USE <database, sysname, AdventureWorks>
|
||||
GO
|
||||
|
||||
BEGIN
|
||||
IF ((SELECT temporal_type FROM SYS.TABLES WHERE object_id = OBJECT_ID('<schema_name, sysname, dbo>.<table_name, sysname, sample_memoryoptimizedtable>', 'U')) = 2)
|
||||
IF ((SELECT temporal_type FROM sys.tables WHERE object_id = OBJECT_ID('<schema_name, sysname, dbo>.<table_name, sysname, sample_memoryoptimizedtable>', 'U')) = 2)
|
||||
BEGIN
|
||||
ALTER TABLE [<schema_name, sysname, dbo>].[<table_name, sysname, sample_memoryoptimizedtable>] SET (SYSTEM_VERSIONING = OFF)
|
||||
END
|
||||
|
||||
@@ -16,7 +16,7 @@ GO
|
||||
|
||||
BEGIN
|
||||
--If table is system-versioned, SYSTEM_VERSIONING must be set to OFF first
|
||||
IF ((SELECT temporal_type FROM SYS.TABLES WHERE object_id = OBJECT_ID('<schema_name, sysname, dbo>.<temporal_table_name, sysname, sample_table>', 'U')) = 2)
|
||||
IF ((SELECT temporal_type FROM sys.tables WHERE object_id = OBJECT_ID('<schema_name, sysname, dbo>.<temporal_table_name, sysname, sample_table>', 'U')) = 2)
|
||||
BEGIN
|
||||
ALTER TABLE [<schema_name, sysname, dbo>].[<temporal_table_name, sysname, sample_table>] SET (SYSTEM_VERSIONING = OFF)
|
||||
END
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
--
|
||||
-- This template creates a table with a CHECK CONSTRAINT,
|
||||
-- then it removes the CHECK CONSTRAINT from the table
|
||||
|
||||
-- Note: The DROP syntax can also be used to drop
|
||||
-- Edge Constraint object types. To achieve this replace
|
||||
-- the constraint_name attribute with the name of the
|
||||
-- respective Edge Constraint object
|
||||
-- ========================================================
|
||||
USE <database, sysname, AdventureWorks>
|
||||
GO
|
||||
|
||||
Reference in New Issue
Block a user