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
/* | |
create table [dbo].[round_robin_test1] | |
with ( distribution = round_robin) as select * from [dbo].[lineitem_source] where 1 = 0 | |
insert into [dbo].[round_robin_test1] | |
select top 157 * from [dbo].[lineitem_source] | |
*/ | |
exec gettbldetails '%round_robin_test1%' | |
SELECT |
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
/* | |
drop table [dbo].[round_robin_test1] | |
create table [dbo].[round_robin_test1] | |
with ( distribution = round_robin) as select * from [dbo].[lineitem_source] | |
where 1 = 0 | |
drop table [dbo].[round_robin_test1] | |
create table [dbo].[round_robin_test1] |
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
create table test_table | |
( | |
col_a int, | |
col_b int | |
) with ( distribution=round_robin) | |
declare @table_object_id bigint; | |
select object_id, * from sys.tables where name like 'test_table' | |
select @table_object_id = object_id from sys.tables where name like 'test_table' |
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
-- distributions | |
select * from sys.pdw_distributions |
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
-- Run against master database | |
SELECT db.name [Database] | |
, ds.edition [Edition] | |
, ds.service_objective [Service Objective] | |
FROM sys.database_service_objectives AS ds | |
JOIN sys.databases AS db ON ds.database_id = db.database_id; |
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
-- Size of dedicated SQL pool | |
SELECT DATABASEPROPERTYEX (DB_NAME(), 'ServiceObjective' ) as ServiceObjective |
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
--https://docs.microsoft.com/en-us/azure/synapse-analytics/sql-data-warehouse/sql-data-warehouse-tables-overview | |
SELECT | |
[Fully Entity Name] = t.full_entity_name, | |
[Schema Name] = t.schema_name, | |
[Entity Name] = t.entity_name, | |
[Current Distribution Method] = t.distribution_method, | |
[Current Distribution Column] = ISNULL(t.distribution_column, '-'), | |
[Current Rows] = SUM(t.rows_count), | |
[Distribution Count] = COUNT(t.rows_count), | |
[Current Data Size on Disk MB] = SUM(t.data_size_MB), |
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
create table dbo.date_test | |
( | |
date_test varchar(100) | |
) | |
insert into dbo.date_test values ('0'); | |
insert into dbo.date_test values ('1901/01/01'); | |
insert into dbo.date_test values ('error'); | |
insert into dbo.date_test values ('2060/01/01'); | |
insert into dbo.date_test values ('013/013/2060'); |
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
create FUNCTION dbo.check_my_date (@value varchar(255)) | |
RETURNS datetime2 | |
as | |
BEGIN | |
declare @rt datetime2; | |
set @rt = convert(datetime2,'19000101') -- default value | |
if @value = '0' -- special case | |
begin |
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
create FUNCTION dbo.check_my_decimal (@value varchar(255)) | |
RETURNS decimal(18,2) | |
as | |
BEGIN | |
declare @rt decimal(18,2) | |
set @rt = try_parse(@value as decimal(18,2)) | |
return @rt; | |
END; |